how to use If .Then structures.

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

how to use If .Then structures.

Postby epsilon » Thu Jan 13, 2011 12:16 pm

I know thats a easy question,and Im already check the topic,but I didnt get the answer,

I made a timer,using onhitbylaser condition to count time, for example, onhitbylaser is scene.my.var1 = scene.my.var1 + 1.

thats clearly,but when the last condition , ?{ scene.my.var1 =5}:{scene.my.var1 =0},it didnt executed, algodoo automaticly transfer to (e)=>{?({scene.my.var1 = 5})(:)({scene.my.var1 = 0})} I dont know whats wrong with it.

thank u for helping me~
epsilon
 
Posts: 9
Joined: Tue Dec 14, 2010 4:05 pm

Re: how to use If .Then structures.

Postby Kilinich » Thu Jan 13, 2011 2:41 pm

if structure:
condition ? true action : false actions

examples:
scene.my.foo == 1 ? {scene.my.foo = 3} : {scene.my.foo = 2};
scene.my.counter = time > 1 ? 1 : 0;

http://www.phunland.com/wiki/Thyme
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: how to use If .Then structures.

Postby epsilon » Thu Jan 13, 2011 3:42 pm

thanks again!
epsilon
 
Posts: 9
Joined: Tue Dec 14, 2010 4:05 pm


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 5 guests