Toggle a variable?

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

Toggle a variable?

Postby ShnitzelKiller » Mon Sep 14, 2009 6:58 am

I know in actionscript it's "variable = !variable" and in lua it's "variable = not variable" and so on, but how can you do such a thing in Thyme?
Image
User avatar
ShnitzelKiller
 
Posts: 49
Joined: Sun Sep 06, 2009 9:42 pm

Re: Toggle a variable?

Postby standardtoaster » Mon Sep 14, 2009 7:04 am

What do you mean by toggle? Are you talking about true and false? If so, scene.my.var == "true" ? {scene.my.var = "false"} : {scene.my.var == "false" ? {scene.my.var = "true"} : {}}
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

Re: Toggle a variable?

Postby ShnitzelKiller » Mon Sep 14, 2009 7:07 am

Am I seeing things, or are those if statements? Are those quotes needed, since it's not a string?

EDIT: i get errors if I paste that code in. What are those extra brackets at the end for?
Image
User avatar
ShnitzelKiller
 
Posts: 49
Joined: Sun Sep 06, 2009 9:42 pm

Re: Toggle a variable?

Postby standardtoaster » Mon Sep 14, 2009 7:17 am

It's late and I messed up. :crazy: scene.my.var == "true" ? {whatever you want if it is true} : {whatever you want to have happen if it is false}
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

Re: Toggle a variable?

Postby ShnitzelKiller » Mon Sep 14, 2009 7:22 am

I still get an error.
Argh. With or without quotations around false and true.

I replaced "whatever you want to be blah blah" with scene.my.var = true and scene.my.var = false. I get an error. Well, two errors.
Image
User avatar
ShnitzelKiller
 
Posts: 49
Joined: Sun Sep 06, 2009 9:42 pm

Re: Toggle a variable?

Postby standardtoaster » Mon Sep 14, 2009 7:37 am

Did you declare scene.my.var in the console ?
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

Re: Toggle a variable?

Postby gradyfitz » Mon Sep 14, 2009 8:02 am

ShnitzelKiller wrote:I know in actionscript it's "variable = !variable" and in lua it's "variable = not variable" and so on, but how can you do such a thing in Thyme?

It is the same in thyme.
Code: Select all
Scene.my.One = ! Scene.my.One

Will switch it from true to false :D, you can also do.
Code: Select all
Scene.my.One = Scene.my.One ? false : true

Both result in the same value :D.
Mechanisms: 18 Mechanisms.
Thyme: Tutorial - Variables/Commands List.
Thymechanic
gradyfitz
 
Posts: 174
Joined: Tue Sep 01, 2009 8:33 am
Location: Victoria, Australia

Re: Toggle a variable?

Postby Dakta » Mon Sep 14, 2009 10:13 am

Really? COOL!
.. ,__,_____
. / __.==--" - - - - - - - - ""
./#(-'
.`-' From http://www.ascii-art.de/. Modded by me to work in Arial. Image
a Mammoth wrote:be boring and interesting.

Mystery wrote:If you were jailbreaker you shouldn't have when't up the 3.1.3
I didn't know you could go up 3.1.3! Thanks Mystery person!
User avatar
Dakta
 
Posts: 417
Joined: Sat Sep 12, 2009 4:36 pm


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 2 guests