Ok this drives me nuts and I have no idea why it is how it is.. I think I'm doing something wrong with the rollout stuff but not sure
this is the code
fn A1 = ( C1(); )
fn C1 = (return true;)
rollout teststuff "test stuff" (
button buttonTestFunction1 "bla";
on buttonTestFunction1 pressed do (
print (A1());
)
)
objEd = newRolloutFloater "mgto EAW scripts" 175 600 10 100
addrollout teststuff objEd;
when I run this script for the first time I get an maxscript error, telling me that C1 is
undefined
when I run the script for the 2nd time I get
true (like expected)
I found already out that a function can only be called after it was created in the script
but
my rollout stuff is at the end of the script.. so after my logic the script should already have found all functions
and WHY does it work after I've closed and restarted the script??
Replies
I need all function above the rollout stuff to be ready bc I will call functions from inside function and they call functions...
So the question is .. Am I doing something wrong or this simply the way maxscript works..
bc if I can't change anything about it I have to try to find an order in all my function where all functions are ready when needed
But if I'm doing something wrong I better learn how to do it right
Generates an error because A1 doesn't know what C1() is. The solution is to swap function definitions so C1 is known before A1 call.
Or use a forward declaration
As a general advice, wrap your test code in brackets. They define a code block avoiding every variable and function definition to clutter the default global scope, thus leading to false behaviours, like working code at second evaluation, but not at first.
thx!