help with oncollide scripts

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

help with oncollide scripts

Postby jessebax129 » Fri Jan 22, 2010 11:35 pm

:cry: i have got a problem: i want to make a scene that locks something, but it has to be an collide script like when it collides, scene.my.speed = 15 but when the laser doesn't collide with anything scene.my.speed has to me 0 so it is like an ''if'''structure but without the collideinformation from the other geom

sorry it's a bit blurry discription but i'm from holland and don't now so well how to explain this in english :oops:
jessebax129
 
Posts: 34
Joined: Tue Jan 05, 2010 6:32 pm

Re: help with oncollide scripts

Postby standardtoaster » Sat Jan 23, 2010 1:29 am

I understand what you mean. Unfortunately you can't activate a script unless it is hitting/touching something.
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

Re: help with oncollide scripts

Postby gradyfitz » Sat Jan 23, 2010 2:30 am

jessebax129 wrote::cry: i have got a problem: i want to make a scene that locks something, but it has to be an collide script like when it collides, scene.my.speed = 15 but when the laser doesn't collide with anything scene.my.speed has to me 0 so it is like an ''if'''structure but without the collideinformation from the other geom

sorry it's a bit blurry discription but i'm from holland and don't now so well how to explain this in english :oops:

I think there's a way to do this, it works by giving a set amount of time before switching off.
First, declare these variable in the console (Tilde ("~"))
Code: Select all
Scene.my.LastTime = 0; Scene.my.Speed = {(Scene.my.LastTime + 0.02) > Sim.time ? {15} : {0}}


In the laser:
Code: Select all
onLaserHit = (e)=>{Scene.my.LastTime = Sim.time}


Hopefully this is what you wanted, if it's not, then just say :).
--
Grady
Mechanisms: 18 Mechanisms.
Thyme: Tutorial - Variables/Commands List.
Thymechanic
gradyfitz
 
Posts: 174
Joined: Tue Sep 01, 2009 8:33 am
Location: Victoria, Australia


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 3 guests