Page 1 of 1

Wait Script

PostPosted: Thu Jun 28, 2018 4:02 pm
by b2lego
Is there a script like "wait 3 seconds" or something of that manner?

Re: Wait Script

PostPosted: Thu Jun 28, 2018 4:08 pm
by b2lego
i did a search and i didnt find anything that fit..

Re: Wait Script

PostPosted: Fri Jul 06, 2018 2:36 am
by Skrubs
Example of a 20 seconds timer that change variable to 1 on object collision:
OnCollide
Code: Select all
(e)=>{timetolive=20}

update
Code: Select all
(e)=>{timetolive<0.02?{timetolive=∞;scene.my.yourvariable=1}:{}}




If you want a script that execute each 10 seconds on object collision for example put the same "timetolive" value in update too example :

OnCollide
Code: Select all
(e)=>{timetolive=10}

update
Code: Select all
(e)=>{timetolive<0.02?{timetolive=10;scene.my.yourvariable=1}:{}}




Or if you want script execute each 10 seconds for example without nothing happend just leave OnCollide empty and set the timetolive to 0.1 like this example:

OnCollide
Code: Select all
(e)=>{}

timeToLive = 0.1
update
Code: Select all
(e)=>{timetolive<0.02?{timetolive=20;yourfunction}:{}}

Re: Wait Script

PostPosted: Sun Aug 05, 2018 1:44 pm
by FRA32
I usually perform time based scripts using a _timer variable(A custom variable added to the object). First you need to enter "_timer=0" into the small black box at the top left of the script menu to register the _timer variable. Then you use it like this:

Somewhere in poststep:

_timer> 0 ? {
_timer = _timer-1/sim.frequency
} : {
_timer > -1 ? {
_timer = -1;
-->{Your script here}<--
} : {}
}

If you want to trigger the timer, just write _timer = X somewhere and replace X with the time until the script should run. Note that this only works with 1 piece of script for each timer, as such you cant just pause any script anywhere, only trigger a specific piece of code after some delay.

Re: Wait Script

PostPosted: Thu Aug 09, 2018 4:41 pm
by b2lego
Thanks very much that helped a lot
:thumbup: