Delete after ___ seconds

If you have problems installing or running Algodoo, have found a bug or need in-game help - this is it!

Delete after ___ seconds

Postby Fujitsu » Fri Sep 04, 2009 7:59 am

I was just wondering whether it was possible to delete a shape after a defined number of seconds/ticks through use of Thyme. If so, how would one implement this?
Image
Gimmie money.
User avatar
Fujitsu
 
Posts: 328
Joined: Tue Sep 01, 2009 12:28 am
Location: Canada

Re: Delete after ___ seconds

Postby gradyfitz » Fri Sep 04, 2009 1:37 pm

Fujitsu wrote:I was just wondering whether it was possible to delete a shape after a defined number of seconds/ticks through use of Thyme. If so, how would one implement this?

Yes :).

  1. Get a link to the density or airFrictionMult (I have had some problems with simple methods recently, so, perhaps try using advanced linkages).
  2. Keep your method of linkage (a variable which you can modify, that will modify the attribute of the other object) in mind, and wherever <linkVariable> pops up here, replace it with the name of your variable.

Ticks:
Code: Select all
Scene.my.Step = 500; // 500 ticks, change this based on how long you want it.
Scene.my.Tick = 0;
Scene.my.ActionArray = [{Scene.my.Tick = Scene.my.Tick + 1},{<linkVariable> = NaN}];
App.numColorsInRainbow = {Scene.my.ActionArray(Scene.my.Tick / Scene.my.Step)();12};


Seconds:
Code: Select all
<linkVariable> = {Sim.time > 10 ? NaN : 1}; // Replace 10 with the number of seconds after the cumulative time of running this scene in this session that it will delete, and replace 1 with the normal value of your object.


Well, That should do :), this is all based on memory, and I think there might have been a problem when Emil fixed a dynamic variable memory leak (which might have caused NaN to crash phun), but I'm not sure, see how it goes :), if it does, for the seconds, replace <linkVariable> with your direct object (put it in--In the script menu).
Mechanisms: 18 Mechanisms.
Thyme: Tutorial - Variables/Commands List.
Thymechanic
gradyfitz
 
Posts: 174
Joined: Tue Sep 01, 2009 8:33 am
Location: Victoria, Australia

Re: Delete after ___ seconds

Postby Fujitsu » Fri Sep 04, 2009 10:38 pm

Would these codes be applicable to a shape that has been spawned a while into the sim?

May I also ask the significance of changing the amount of coloured rays refracted from a white laser?
Image
Gimmie money.
User avatar
Fujitsu
 
Posts: 328
Joined: Tue Sep 01, 2009 12:28 am
Location: Canada

Re: Delete after ___ seconds

Postby gradyfitz » Sat Sep 05, 2009 4:33 am

Fujitsu wrote:Would these codes be applicable to a shape that has been spawned a while into the sim?

Yes, just make sure to add the time from when you started to the number of seconds (only for the seconds method, the ticks method is independent of the simulation).

Fujitsu wrote:May I also ask the significance of changing the amount of coloured rays refracted from a white laser?

You can choose any constantly updated variable, but, I chose App.numColorsInRainbow because I didn't think it would be changed very commonly (if you do modify it, change the number "12" from it into whatever you modified it to :)).

It's not specifically the App.numColorsInRainbow variable that has to be changed this way :).

Hardly anyone seems to understand this method of timer :), so don't worry if you don't.
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 Help / Bug reports

Who is online

Users browsing this forum: No registered users and 5 guests