PDA

View Full Version : Check for errors and clean me up.


displaced
07-06-2007, 08:14 AM
Hi...

well i would say im still quite a newbie at all this maxscript.....but ive managed to chop together various bits of code that i have managed to get my hands on from various sites and people who have helped me out...

Now im getting some errors with this script but it doenst happen all the time...and my debug skills are not up to speed just yet so i can't track the problem down....

it occurs when you press render and "spinirrmin" generates an error.

I was also wondering if anyone would be interested in cleaning up my code....i know it sounds rude for me to ask but i think it would be quite a good learning experience...as a newbie i feel when i write code i will do anything to make it work...so it may not be the most efficient.

well to give you brief overview....its to help with vray and making a render dialog thats has the most used elements in one place....plus it also spits out three render one for lightcache one for irradience and one for main render.

Any help would be great thanks.

davestewart
07-06-2007, 11:40 AM
Hey,
Took a very quick squiz at the code in notepad. You seem to have a good grasp of various control structures and syntax. Wihout getting into what it "does" I would just say you need to make it a bit more human-readable. By that I mean:

Be more liberal with your comments.




Break it up into sections such as "declarations", "functions", "handlers"
Add comments next to blocks and sub-blocks of code so that someone quickly scanning the code can see the kinds of things you're trying to accomplish.
I also use lines of --------------------------------------------------- to make "visual" boundaries in the code.
Variables

Use camelCaseVariableNames as they are easier to read (and remember) than alllowercasevariablenames
You have a lot of assignments! One thing I like to do to keep code readable is where I have a block of assignments, I like to range all the "= someValue" in a column (using tabs). It makes it easier to analyse: thisLongVariable = 1
var = 2
Structure:

Also, use tabs, not spaces! Maybe your editor (or mine) mashed them though...
White spae is GOOD. It makes it easy to scan a large script (such as your's) and visualize blocks of code.
Coding style can be very personal, although it pays to stick to perceived "good practices". There is not a wong or right way to code, but certain practices are more effective than others.

Here's an example of the way I code. It might not be for everyone, but it is easy to read (IMO). Link here (http://www.davestewart.co.uk/code/lang/maxscript/workflow/Viewport%20Layout%20Manager/Viewport%20Layout%20Manager%201.2.ms)

dutch_delight
07-06-2007, 12:38 PM
Bit cheeky hacking some code together and then asking someone else to fix it as an exercise!!!

What is the error message you are getting?

displaced
07-06-2007, 12:59 PM
The error is in the function below


fn Collectsettings.
"gi_irradmap_minRate = vrqrender.spinirrmin.value"


Thanks davestewart for your response

CGTalk Moderation
07-06-2007, 12:59 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.