" ? :" not work ?

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

" ? :" not work ?

Postby dogwong » Wed Oct 21, 2009 12:32 pm

here:
(e)=>{(x)=>{scene.my.auto_drive_speed = 6 ? {scene.my.auto_drive_speed = 3}}}
but it seems not working....
i wanna do this:
when scene.my.auto_drive_speed = 6 then
scene.my.auto_drive_speed become 3

please help....thanks
dogwong
 
Posts: 8
Joined: Wed Oct 21, 2009 12:28 pm

Re: " ? :" not work ?

Postby Sniperkasa » Wed Oct 21, 2009 1:03 pm

(e)=>{scene.my.auto_drive_speed == 6 ? {scene.my.auto_drive_speed = 3} : {} }
There you go?
If you have a question, have a dollar and call somebody that cares.
No really just PM me if you have a problem :)
User avatar
Sniperkasa
 
Posts: 493
Joined: Tue Sep 01, 2009 5:34 pm
Location: The bottom of a lake.

Re: " ? :" not work ?

Postby gradyfitz » Wed Oct 21, 2009 1:06 pm

dogwong wrote:here:
(e)=>{(x)=>{scene.my.auto_drive_speed = 6 ? {scene.my.auto_drive_speed = 3}}}
but it seems not working....
i wanna do this:
when scene.my.auto_drive_speed = 6 then
scene.my.auto_drive_speed become 3

please help....thanks

The reason is that <X> = <Y> assigns <X> to <Y>, the infixed operation of "? :" requires a true/false (boolean) value, this can be achieved using the equality operator ("==") or the other operators (">", "<", ">=", "<=" and "!="), the infixed if_then_else structure also requires both then and else structures too, it will not work if you only send the boolean value and the then or else functions.

The code you seem to want is:
Code: Select all
(e)=>{Scene.my.auto_drive_speed == 6 ? {Scene.my.auto_drive_speed = 3} : {}}


Hopefully this helped.
/Grady
Mechanisms: 18 Mechanisms.
Thyme: Tutorial - Variables/Commands List.
Thymechanic
gradyfitz
 
Posts: 174
Joined: Tue Sep 01, 2009 8:33 am
Location: Victoria, Australia

Re: " ? :" not work ?

Postby dogwong » Wed Oct 21, 2009 1:21 pm

oh it is work, thank you! :clap:
dogwong
 
Posts: 8
Joined: Wed Oct 21, 2009 12:28 pm

Re: " ? :" not work ?

Postby Sniperkasa » Wed Oct 21, 2009 7:47 pm

Grady that code is like copy pasted from mine and i got no thank yous :cry:
And I even posted before you Image
If you have a question, have a dollar and call somebody that cares.
No really just PM me if you have a problem :)
User avatar
Sniperkasa
 
Posts: 493
Joined: Tue Sep 01, 2009 5:34 pm
Location: The bottom of a lake.

Re: " ? :" not work ?

Postby gradyfitz » Thu Oct 22, 2009 8:06 am

Sniperkasa wrote:Grady that code is like copy pasted from mine and i got no thank yous :cry:
And I even posted before you Image

Sorry, I didn't copy and paste it from your post, nor did I read your post before I clicked the "Submit" button, I finished writing my post then finished watching the show on TV (it's on ABC, so there were no ads where I'd finish the last line, there was about 10 minutes to go when I finished writing my post). I prefer to explain why it didn't work, how to do it the correct way, and perhaps one way the system could be achieved :D. A lot of the time, I forget I was even writing a post, though that happens far less now because of the new forum system (I checked all the posts before I posted again (and because of it, got distracted) in the old forum system, but in the new forum system, I don't have to worry about all the new post marks disappearing and having to look for the new posts manually). It rarely hurts to have a second person to help though :D.

Sorry if it looked like I copied you, but that's not what happened :).
Mechanisms: 18 Mechanisms.
Thyme: Tutorial - Variables/Commands List.
Thymechanic
gradyfitz
 
Posts: 174
Joined: Tue Sep 01, 2009 8:33 am
Location: Victoria, Australia

Re: " ? :" not work ?

Postby Sniperkasa » Thu Oct 22, 2009 2:07 pm

Yes but it looks like I'm not even noticed for trying to help :?
He only replied once you posted.. generally same thing as I with an explanation.. :|
But never mind I'm getting used to this allready..
If you have a question, have a dollar and call somebody that cares.
No really just PM me if you have a problem :)
User avatar
Sniperkasa
 
Posts: 493
Joined: Tue Sep 01, 2009 5:34 pm
Location: The bottom of a lake.


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 7 guests