Page 1 of 1
Toggle a variable?
Posted:
Mon Sep 14, 2009 6:58 am
by ShnitzelKiller
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?
Re: Toggle a variable?
Posted:
Mon Sep 14, 2009 7:04 am
by standardtoaster
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"} : {}}
Re: Toggle a variable?
Posted:
Mon Sep 14, 2009 7:07 am
by ShnitzelKiller
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?
Re: Toggle a variable?
Posted:
Mon Sep 14, 2009 7:17 am
by standardtoaster
It's late and I messed up.
scene.my.var == "true" ? {whatever you want if it is true} : {whatever you want to have happen if it is false}
Re: Toggle a variable?
Posted:
Mon Sep 14, 2009 7:22 am
by ShnitzelKiller
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.
Re: Toggle a variable?
Posted:
Mon Sep 14, 2009 7:37 am
by standardtoaster
Did you declare scene.my.var in the console ?
Re: Toggle a variable?
Posted:
Mon Sep 14, 2009 8:02 am
by gradyfitz
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
, you can also do.
- Code: Select all
Scene.my.One = Scene.my.One ? false : true
Both result in the same value
.
Re: Toggle a variable?
Posted:
Mon Sep 14, 2009 10:13 am
by Dakta
Really? COOL!