Delay?

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

Delay?

Postby Sonic » Tue Mar 16, 2010 9:10 pm

I'm trying to make a scene where I use a laser to change the attraction of an object, then change back when it hits again. But when the laser hits it it runs the script every step. How do I put in a 1 or 2 second delay?

Here's my script I'm using:
Code: Select all
(e)=>{attraction = -10000 - attraction}
I do stuff and break things. You know how it is.
Image
User avatar
Sonic
 
Posts: 1467
Joined: Tue Sep 01, 2009 6:18 pm
Location: America!!!

Re: Delay?

Postby Kilinich » Tue Mar 16, 2010 9:41 pm

(e)=>{sim.time > controllerAcc ? {controllerAcc = sim.time+10; {do something}} : {} }
and don't forget to reset controlleAcc to zero.
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Delay?

Postby Sonic » Tue Mar 16, 2010 9:44 pm

K thanks.
I do stuff and break things. You know how it is.
Image
User avatar
Sonic
 
Posts: 1467
Joined: Tue Sep 01, 2009 6:18 pm
Location: America!!!

Re: Delay?

Postby Rideg » Thu Mar 18, 2010 8:37 am

Code: Select all
(e)=>{(e.geom.controllerAcc - sim.time) >= 2 ? {attraction = -10000 - attraction; e.geom.controllerAcc = sim.time}:{}}


This is pretty much the same I think it's a little easier to see how it works.
Image
make sure to check out my work.
User avatar
Rideg
 
Posts: 948
Joined: Tue Dec 15, 2009 5:17 pm
Location: Östersund, Sweden

Re: Delay?

Postby sheepborg » Sun Mar 21, 2010 5:25 am

wait what is e.geom.controllerAcc ???
BTC: 12wcLxBejr6rhCk6WPyVSNmkjwwbxXEvBG
LTC: LQ17UdL71xzLCprSfkoWUQXDXWuHjx2nf9
FTC: 6nfbPuFbtk8uNokYSsVfbzc5393ggxNGDC

polygons > textures

STUFFES:
http://www.algodoo.com/algobox/profile.php?id=4540
User avatar
sheepborg
 
Posts: 203
Joined: Sat Dec 05, 2009 10:44 pm
Location: North Carolina USA

Re: Delay?

Postby RicH » Sun Mar 21, 2010 5:29 am

I'm sure your aware of the geometry controllers(that thing that can make you move objects with the arrow keys). It's a property of any geometry. It's been commonly used now to store properties in an object and such.
Millions of voices suddenly cried out in terror, and were suddenly silenced. Something terrible has happened.
User avatar
RicH
[Funniest Person 2010]
 
Posts: 2043
Joined: Tue Sep 01, 2009 9:01 am

Re: Delay?

Postby Rideg » Sun Mar 21, 2010 11:24 pm

it can be anything you wont have any need of. Just a "storage for numbers" you could also use a variable
Code: Select all
(e)=>{(scene.my.anything - sim.time) >= 2 ? {attraction = -10000 - attraction; scene.my.anything = sim.time}:{}}
;P
Image
make sure to check out my work.
User avatar
Rideg
 
Posts: 948
Joined: Tue Dec 15, 2009 5:17 pm
Location: Östersund, Sweden

Re: Delay?

Postby Sonic » Sun Mar 21, 2010 11:25 pm

Whatever guys. It didn't work anyway, so I used a key bind.
I do stuff and break things. You know how it is.
Image
User avatar
Sonic
 
Posts: 1467
Joined: Tue Sep 01, 2009 6:18 pm
Location: America!!!

Re: Delay?

Postby RA2lover » Mon Mar 22, 2010 6:48 pm

keybinds do leak to config files, so its not a very good idea.
Jrv wrote:
TC42 wrote:Quite honestly, I didn't think anyone on 4chan has that good a use of grammar, spelling, usage, mechanics, ect.
But I've never been there, so I may be wrong.


GTFO newfgt
User avatar
RA2lover
 
Posts: 607
Joined: Mon Aug 31, 2009 8:43 pm
Location: Brazil

Re: Delay?

Postby Sonic » Mon Mar 22, 2010 6:59 pm

It's localized. It just affects an object in the scene, nothing more.
I do stuff and break things. You know how it is.
Image
User avatar
Sonic
 
Posts: 1467
Joined: Tue Sep 01, 2009 6:18 pm
Location: America!!!


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 14 guests