Variables initializing

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

Variables initializing

Postby krzat » Sat May 15, 2010 2:34 pm

I have found method to initialize local variables (Algodoo destroys them after exit).

Example:
Code: Select all
e.geom.ini = yourvar;
e.geom.yourvar = 0;
yourvar = ini;


So after load yourvar will be set to 0. With that you can use if and functions (they won't work if variable doesn't exist).

Useful example: laser timer.
Input: time, pause
Output: time
Code: Select all
(e)=>{
    e.geom.ini = timer;
    e.geom.timer = 0; //initializes timer to 0 on scene start
    timer = ini;

    e.geom.ini = pause;
    e.geom.pause = 0; //same here for pause switch
    pause = ini;

    pause == 1 ? {pause = 0} : {timer = timer + 1};
    text = timer + ""
}
krzat
 
Posts: 11
Joined: Fri Sep 04, 2009 3:36 pm

Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 18 guests