If laser is hitting...

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

If laser is hitting...

Postby The mask » Sat Feb 27, 2010 11:18 pm

Could anyone explain me how to change a variable when a laser is hitting and change it again when it stops hitting an object? :roll:


For example I've got a box and a laser when the laser hits the box scene.my.var1 = 0 and when it stops hitting the box scene.my.var1 = 1.

It could be used as a kind of movement sensor or tilting sensor just like here:

Rating: rated 5
Filesize: 9.06 kB
Comments: 0
Ratings: 1
download
Image
User avatar
The mask
 
Posts: 6
Joined: Sat Jan 23, 2010 6:43 pm

Re: If laser is hitting...

Postby StephenAlverez » Sun Feb 28, 2010 1:09 am

Take a circle and put an offcenter motor in it, put it at +inf strength and 600 rpm, and put that circles on collide to scene.my.var1=1.
I am Alpha and Omega, the beggining and the end.

Image
User avatar
StephenAlverez
 
Posts: 164
Joined: Wed Sep 30, 2009 2:46 am
Location: Vermont

Re: If laser is hitting...

Postby Mr_Stabby » Thu Mar 04, 2010 9:12 am

if its motion sensor you want use this in laser

Code: Select all
(e)=> {e.laser.color==[1,0,0,1]?{e.laser.color=[e.pos(0), e.pos(1), 0, 1]}:{}; e.pos != [e.laser.color(0), e.laser.color(1), 0, 1]?{scene.my.var=1}:{scene.my.var=0} }


yells when anything tries to pass under it but you cant move it unless you compensate with extra scripting to reevaluate its default pos when moved, another way would be

Code: Select all
(e)=>{check=0; check=e.geom.entityID; check==0?{e.geom.entityID:=1; app.step; app.undo}:{}; e.laser.color==[1,0, 0, 1]?{e.laser.color=[e.geom.entityID, 0, 0, 1]}:{}; e.geom.entityID!=e.laser.color(0)?{scene.my.var=1}:{scene.my.var=0}}


doesent detect motion but rather what object its hitting, immune to movement as long as the default backstop remains the same
Mr_Stabby
 
Posts: 155
Joined: Wed Dec 16, 2009 12:16 am


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 6 guests

cron