If in thyme ?

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

If in thyme ?

Postby Skrubs » Tue Mar 06, 2018 7:39 pm

I want to create a script that when a value of a variable x is > 3 move the variable y to 5.
Skrubs
 
Posts: 16
Joined: Tue Mar 06, 2018 7:36 pm

Re: If in thyme ?

Postby Kilinich » Wed Mar 07, 2018 2:58 pm

{condition} ? {then code} : {else code}

x > 3 ? {y = 5} : {};
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: If in thyme ?

Postby Skrubs » Sun May 20, 2018 11:50 pm

How to add 2 ifs ?
Skrubs
 
Posts: 16
Joined: Tue Mar 06, 2018 7:36 pm

Re: If in thyme ?

Postby FRA32 » Tue Jun 05, 2018 6:20 pm

You can combine conditions using && and ||. && means "And", || means "or".

pos(1)>3 && vel(1)<0 ? {}: {}
This means if pos(1) is > 3 AND vel(1) is < 0 THEN do stuff.

vel(0) > 10 || color(3)<=0.1 ? {}: {}
if vel(0) is greater 10 OR color(3) is less or equal 0.1, THEN do stuff.
FRA32
 
Posts: 229
Joined: Wed Dec 03, 2014 9:51 pm


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 7 guests

cron