Variables
-
Found out a bit more about ruby variables; turns out you can set variables properly without setVar or getVar:
@var
That's it! To set, use:
@var=1
You can't use it properly with onTouch, but once onUnTouch comes that won't be a problem either. The thing is, it's not working how it's supposed to; it's acting like a global variable. It should be specific to a certain object... technically, $var is a global variable, but it appears to work the same.
-
Is that code there setVar or getVar subsitute
-
It's just the ruby script way. I guess the @/@@/$ bit saves it, so it works between frames, unlike normal ruby variables
-
That will work. But you should be aware of a few things:
Some variables names could cause things to break. For example @frame is already being used and if you override it could break things.
If you use something like "@foo" the value will be the same for all objects. Same as getVar and setVar are now. But in a future version each object will have its own version of "@foo". So keep in mind that a model that uses "@foo" now will change behavior when that version comes out.
Advertisement