Friday, August 3, 2012

Some great Maxscript lessons

Lesson 8: Scopes – Why has my script stopped working?

The whole concept of scopes confused me for a very very long time, I had no idea what it meant and I ran into so many problems which could have easily been solved if I simply understood the scope of my variables… right so you’re probably scared already, but as a beginner maxscript you might have already run into this issue before, classic example of when/why you need to understand scopes… You test out some code in the maxscript listener, you make a nice interface, put your code into it, you’ve got a working tool, it works, you’re happy, you go have a beer in the pub, come in the next day, start up max, load up your new amazing script to show your boss and suddenly there’s an error message that wasn’t there before! When I was first learning maxscript this happened a lot and I simply couldn’t understand why it was happening. There are loads of thread on CgTalk which are titled “Script doesn’t run on first run”, or “Script doesn’t work after I restart max”.
So lets try recreate these mysterious conditions….in a really simple example.

No comments:

Post a Comment