[Help] If statement.. continuously refreshing

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

[Help] If statement.. continuously refreshing

Postby RpT » Sun Oct 02, 2011 5:06 pm

Hi to all! I'm new on this forum but I've been playing Algodoo and Phun(a long time ago) since 2-3 years(don't know exactely). I've just started to learn thyme scripting. I'm already facing a problem :crazy: so I hope that you, guys, would help me.
So here it is :
I want to change the collision layer depending by the angular velocity of a wheel. I decided to use an "if statement". I have a working statement :
Code: Select all
scene.my.boxangularvelocity < 10 ? {scene.my.gear1=1} : {scene.my.gear1=2}


Where:
-scene.my.boxangularvelocity is refreshed by gradyfitz's new method ( and I can get the correct value)
-scene.my.gear1 is the collision number that I want... for1=A first gear ..for 2=B second gear... and so on.

It works only ONCE when I put that statement in the console and press Enter. I need it to work every second of the simulation. So here is my question: How can I make that statement not only work once but every time(every one second or every 2 seconds) without putting that if statement in console and pressing Enter. Thanks for help!
Țăranul se uită la pământ și pământul la țăran..dacă are pământ, dacă nu, atunci nu!

:lol:
RpT
 
Posts: 11
Joined: Sun Oct 02, 2011 4:45 pm

Re: [Help] If statement.. continuously refreshing

Postby monstertje3 » Sun Oct 02, 2011 5:34 pm

create a laser and put your if-statement in the onlaserhit of the laser, should be continious.
for phun it would be a rotating box against an other geom for continious collision.
that way you dont have to enter anything anymore :P
Basically, there are only 10 types of people in the world. Those who know binary, and those who don't.
Light travels faster than sound. That's why some people appear bright until they open their mouths.
User avatar
monstertje3
 
Posts: 343
Joined: Sat Sep 05, 2009 4:29 pm
Location: N-H, NL

Re: [Help] If statement.. continuously refreshing

Postby RpT » Sun Oct 02, 2011 5:55 pm

Thanks ! :D
Also do you have any ideea how to make the refreshing rate a little bit lower... because it lags much and I cannot control anything. I tried by interrupting the laser beam with a rotating piece of wood but when the beam collides with the spinning wheel the wood's hinge stops working.
I need to interrupt somehow the refresher= the laser beam which goes to the spinning wheel.

Thank you for giving me your lost time :D
Țăranul se uită la pământ și pământul la țăran..dacă are pământ, dacă nu, atunci nu!

:lol:
RpT
 
Posts: 11
Joined: Sun Oct 02, 2011 4:45 pm

Re: [Help] If statement.. continuously refreshing

Postby monstertje3 » Sun Oct 02, 2011 7:13 pm

you could put the script on a the box which the laser hits, (onlaserhit) and then the interuptor will work,

Code: Select all
controlleracc>10 ? {scene.my.boxangularvelocity < 10 ? {scene.my.gear1=1} : {scene.my.gear1=2};controlleracc=0} : {controlleracc+1}

will also work, where controlleracc>10 can be configured to any delay (higher for longer pause)
Basically, there are only 10 types of people in the world. Those who know binary, and those who don't.
Light travels faster than sound. That's why some people appear bright until they open their mouths.
User avatar
monstertje3
 
Posts: 343
Joined: Sat Sep 05, 2009 4:29 pm
Location: N-H, NL

Re: [Help] If statement.. continuously refreshing

Postby RpT » Mon Oct 03, 2011 5:46 pm

Thank you very much ! :D
Țăranul se uită la pământ și pământul la țăran..dacă are pământ, dacă nu, atunci nu!

:lol:
RpT
 
Posts: 11
Joined: Sun Oct 02, 2011 4:45 pm


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 2 guests