[help] If statement in oncollide

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

[help] If statement in oncollide

Postby killalltheyuppies » Sat Mar 20, 2010 11:08 am

How would I form a simple if then else statement in an oncollide script?
For instance if my.scene.variable>100 Then my.scene.bool=1 Else my.scene.bool=0

Thanks in advance.
killalltheyuppies
 
Posts: 1
Joined: Sat Mar 20, 2010 11:05 am

Re: [help] If statement in oncollide

Postby Mystery » Sat Mar 20, 2010 1:10 pm

Code: Select all
{my.scene.variable > 100}?{my.scene.bool = 1}:{my.scene.bool=0}


{If}?{Then}:{Else}
User avatar
Mystery
 
Posts: 2802
Joined: Thu Sep 03, 2009 1:16 pm
Location: Southern Australia

Re: [help] If statement in oncollide

Postby Kilinich » Sat Mar 20, 2010 1:50 pm

Mystery wrote:
Code: Select all
{my.scene.variable > 100}?{my.scene.bool = 1}:{my.scene.bool=0}


{If}?{Then}:{Else}

almost.

if ? then : else

where if is boolean, than and else - anything, include procedure {}

for example:

1 > 2 ? 3 : 4
gives you
4

and you can include that in some operations like:

scene.my.begining = sim.time < 10 ? 1 : 0
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: [help] If statement in oncollide

Postby Chronos » Sat Mar 20, 2010 2:08 pm

Is it really that hard to search? Or maybe look at the damn tutorial topic that's been stickied?
TheWinkits wrote:They both looks of cuking amazing
User avatar
Chronos
[Most Active Member 2010]
 
Posts: 4457
Joined: Mon Aug 31, 2009 6:00 pm
Location: Californania

Re: [help] If statement in oncollide

Postby Mystery » Sat Mar 20, 2010 2:10 pm

Well now if anyone does search they will find a nice simple topic with the answers already posted.

Also
Kilinich wrote:
Mystery wrote:
Code: Select all
{my.scene.variable > 100}?{my.scene.bool = 1}:{my.scene.bool=0}


{If}?{Then}:{Else}

almost.

if ? then : else

where if is boolean, than and else - anything, include procedure {}

for example:

1 > 2 ? 3 : 4
gives you
4

and you can include that in some operations like:

scene.my.begining = sim.time < 10 ? 1 : 0


My way works fine, i prefer it as it makes it easier to edit and read i find it more organised, a lot of my code is like that.
User avatar
Mystery
 
Posts: 2802
Joined: Thu Sep 03, 2009 1:16 pm
Location: Southern Australia


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 16 guests

cron