Diference between scene.my.variable/controlleracc/_*variable

About advanced scenes, and the Thyme scripting language used in Algodoo.

Diference between scene.my.variable/controlleracc/_*variable

Postby francky380a380 » Sun Mar 30, 2014 10:44 pm

hi everyone, I'm a beginner in thyme scripting and I'm asking me few questions.

I alway use scene.my.variable in my scripts but I readed that I can use _variable and even controlleacc := **. Is it true, why I have to prefer the other than scene.my.variable, what's the difference and How to use them ?

Thanks a lot

(Moreover, where can i found a post, a text which explain me all the variables in the script box like (controlleracc, geomID, bendconstant, bendtarget, etc . . .) because I always see them in script but I don't know their usefullness).
francky380a380
 
Posts: 48
Joined: Tue Dec 17, 2013 8:12 pm

Re: Diference between scene.my.variable/controlleracc/_*variable

Postby electronicboy » Mon Mar 31, 2014 2:03 am

Scene.my.* - Global namespace, any variables created inside this area will be exported with the scene, allowing you to use functions inside your scenes.

_variable - Geom serialiased, Any variable which isn't one of the "default" names will be removed in the process of exporting the scene to a save file, unless they start with an _, in which case they will be saved with the scene.

controlleracc, is one of the many variables which are on a geometry when it's created, unless you're using the geometry controller for moving an object, this variable is unused, so before we had _variables, we used the controlleracc for storing a variable inside.

Also, if you check on this forum, there should be a sticky with an outdated list of variables, if you're looking for something, try using the search tool or asking on this section of the forum.
When asking for help, READ THE STICKIES!
electronicboy
 
Posts: 1694
Joined: Mon Aug 31, 2009 6:18 pm

Re: Diference between scene.my.variable/controlleracc/_*variable

Postby francky380a380 » Tue Apr 01, 2014 6:04 pm

Okay, so if i understood, _variable is very specific, controlleracc is very old so when i use scene.my.variable it's the best ?

that's what i did for controlleracc (that's why i ask here because i didn't understand everything) but i only founded strange results that didn't give me satisfying answer.

(I'm french, sorry for my inglish ^^)
francky380a380
 
Posts: 48
Joined: Tue Dec 17, 2013 8:12 pm

Re: Diference between scene.my.variable/controlleracc/_*variable

Postby electronicboy » Tue Apr 01, 2014 11:31 pm

Okay, controlleracc was used before we had to _variables on geometries, before the _variable was implimented, storing values was hard and using controlleracc was the only way to actually do it.

Also, scene.my.variable is what us programmers would refer to as a global variable, it's accessible and writable by all code on the scene, while _variables are considered local, and can only me modified by code running directly on that object or a colliding object running code onto another object.


In programming, one of the many ways to class variables are local and global.

As stated above, a global variable is accessible from all code no matter where it is.
A local variable is only accessible from the function which creates it. (however in algodoo it is a little more open with the e.other collision event)
When asking for help, READ THE STICKIES!
electronicboy
 
Posts: 1694
Joined: Mon Aug 31, 2009 6:18 pm


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 5 guests