Motor CW or CCW if/then

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

Motor CW or CCW if/then

Postby dsengere » Fri Jan 22, 2010 10:32 pm

Hi, I have a very simple question. Where/how can I change whether a motor turns left or right depending on an input? In this case it's when a variable I have is positive or negative.

Thanks!
dsengere
 
Posts: 12
Joined: Thu Oct 22, 2009 5:49 pm

Re: Motor CW or CCW if/then

Postby standardtoaster » Fri Jan 22, 2010 10:51 pm

Make two variables. One called Scene.my.motor and the other one called Scene.my.var
Code: Select all
Scene.my.motor = true; Scene.my.var = 1

Click on the hinge that you want this to affect. Go to its motor script box and put:
Code: Select all
{Scene.my.motor}

In the onCollide/onHitByLaser/onLaserHit put:
Code: Select all
Scene.my.var < 0 ? {Scene.my.motor = false} : {Scene.my.motor = true}
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

Re: Motor CW or CCW if/then

Postby dsengere » Sat Jan 23, 2010 1:27 am

I actually had to put scene.my.motor in the CCW box, but thanks!
dsengere
 
Posts: 12
Joined: Thu Oct 22, 2009 5:49 pm


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 12 guests