[Closed] Changing a rollout value from a callback?
I’ve got a time change callback going and want to dynamically update a rollout parameter everytime the slider moves, but it comes out as undefined, since the callback function is before the rollout definitions.
What’s the best way to get around this issue? The answer is probably right in front of me, but i’m sleepy right now and i’m not thinking straight.
First declare the rollout variable, best as GLOBAL, then define the callback and then define the rollout. (Of course, if you can define the rollout first and the callback later, it would be easier). In general, it is a good practice to declare rollout variables as global esp. when used as dialogs in order to be able to close them, and it also gives you access to the rollout values from both the Listener and other scripts. Just remember to give the variable a long descriptive and very unique name to avoid collisions with other scripts.
“a_Rollout” is a bad idea.
“myProject_MyToolRolloutName_Rollout” is much better…
Thanks Bobo. It actually never occured to me that you could globalise those names… i’d got it into my head that it was reserved for function/event variables only… and rollout UI names were more like #DEFINEs.
MXS is very relaxed when it comes to variables. Variables can contains ANYTHING – objects, rollouts, floaters, numbers, arrays, structs, functions and so on. In most cases, you can declare a variable as global and then stick whatever you want in it, and even change the content on the fly (which is a bad practice, but it is technically allowed) – for example you can initialize the variable
global a = 10
and later store a TriMesh value into it, then overwirte it with a node path, and even later with a rollout definition… There is nothing that would stop you from doing that, except probably logic…
Thanks bobo for the useful information. And time to explain why and why not.
keep searching for the post you reply for learning more how to use maxscript, bought your two dvds really happy with i leran with them.
Thanks for the big support for the comunnity.