I’m not sure why but I cannot seem to get this to work. I’m making a quick GUI for setting up props and when I select a button I have a symbol button with the props image show up, then i want a variable to change to its number: no props = 0, prop 1 =1, prop 2 = 2 and so on. however i’m setting it up like this.
your equality tests are wrong: they have one = , not ==. When put in brackets, they get evaluated: ($propN = 1) will always equal 1 and so thats what you get back.
ahh thank you! I tried the == but i was getting an error but puting the (int $propN) worked like a charm! Thank you Theodox!
Hmm, now how can I change the variable from a procedure? This is what im using for the prop icon button:
proc stone(){
button -edit -vis 1 stoneMain;
button -edit -vis 0 grassMain;
global int $propN = 1;
}
This however will not change the $propN value and will remain the same. running “global int $propN = 1” by itself will. Why wont it while inside a procedure?
Or, best of all – avoid global variables like the plague they are. Just return the updated incremented number from the procedure as it is called, then you don’t have to worry about some other script that also uses the same global name for some other purpose
Yup, seconded. Even if this is data that you need to keep between separate executions of a script then I’d store it in a node in the scene (if it’s scene specific) or write it to a cfg/ini file rather than use globals.