Limiting events

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

Limiting events

Postby Mr_Stabby » Thu Jan 14, 2010 11:21 pm

Made a big script that even after optimization is rather slow, i think the problem is that it runs onlaserhit and that happens alot each frame (alltho i could easily deal with the script firing only once every few frames). Does anybody know a way to limit the frequency a laser triggers a script?
Mr_Stabby
 
Posts: 155
Joined: Wed Dec 16, 2009 12:16 am

Re: Limiting events

Postby Mr_Stabby » Thu Jan 14, 2010 11:59 pm

Rating: rated 5.5
Filesize: 51.54 kB
Comments: 5
Ratings: 2
download


heres the thingy im working on, while one piston like that is fine 4+ is already a significant performance hit
Mr_Stabby
 
Posts: 155
Joined: Wed Dec 16, 2009 12:16 am

Re: Limiting events

Postby standardtoaster » Fri Jan 15, 2010 12:08 am

I'll take a look at it as soon as I can. (about 10-30 mins from now)
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

Re: Limiting events

Postby standardtoaster » Fri Jan 15, 2010 12:46 am

I can tell you that it would have been easier to just script a spring but I can tell that changing collision layers could make it more reliable. I would also like to suggest that you use Scene.my.* instead of targ = x. The reason that it lags is because you have the laser switching collision layers almost every frame. Here's a good fix:
Code: Select all
controllerAcc = controllerAcc + 1;     controllerAcc > 2 ? {         controllerAcc = 0;         targ = scene.my.var * 0.1;         targ > 1.3 ? {targ = 1.3} : {};         density = targ;         textColor = [targ, 1, 1, 1];         e.laser.color = textColor;         e.laser.collideSet = 4     } : {}

I put that into the Info Relay boxes. it runs a lot faster now. You can adjust how fast/slow it updates by changing the number that the controllerAcc is being compared against. In this case, the number is two.
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

Re: Limiting events

Postby Mr_Stabby » Sun Jan 17, 2010 3:27 am

the reason why i used the laser or didnt just make a scripted spring in the first place is because this way its completely independant of global variables, giving it the portability i try to give all my creations
Mr_Stabby
 
Posts: 155
Joined: Wed Dec 16, 2009 12:16 am

Re: Limiting events

Postby standardtoaster » Sun Jan 17, 2010 4:17 am

After I looked at the scene a bit more I noticed that using your method could be a bit more effect as suspension than a spring could.
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

Re: Limiting events

Postby Mr_Stabby » Sun Jan 17, 2010 6:29 am

yes well i finally got around to puting the piston to use by installing it into a very basic vehicle, i used a laser to measure the distance from ground and scripted it so that each piston would do its best to keep a fixed distance from the ground. the results were interesting - all the rotational inertia regular vehicles gather while moving over rough terrain was gone so basically it became near impossible to flip it via jumping off something or landing or crashing into something, it also retained a really stable distance from the ground at all times which would have been great for maximum amount of wheel-ground contact but unfortunately due to the design of the piston with its 12 levels its way too jerky and thus overall moved slower then its spring suspended counterparts because it kept bouncing the wheels off the ground all the time... hence why im abandoning this particular design and am gonna try to figure out some other way to do it.
Mr_Stabby
 
Posts: 155
Joined: Wed Dec 16, 2009 12:16 am

Re: Limiting events

Postby standardtoaster » Sun Jan 17, 2010 6:46 am

It's to bad that you're dropping this design. I liked it. :) I do look forward to the next one, though.
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 6 guests