kirkwoodwest
Junior Member
Building Lemur Templates for Live and Studio
Posts: 47
|
Post by kirkwoodwest on Mar 6, 2019 17:02:14 GMT
This question came up on the facebook user group today about wanting to put a delay in script. In general this is not the best behavior in any system because it would stop the entire code execution so nothing else can process while this goes on. The boys at jazzmutant figured out a better way... Not going to go into details about this now. I'm late for work... but I attached an example in the meantime: wait_timer.jzml (6.52 KB) Edit: check out Also check out xPsycHoWasPx's post below for how to do the same with Expressions.
|
|
|
Post by xPsycHoWasPx on Mar 6, 2019 17:20:44 GMT
this talk have already been discussed in this thread (Just posting this as alternative to the OnFrame method ) lemur.boards.net/post/134(method +download is shown) only problem with the onFrame as trigger is now you got a script that runs 60 times pr sec always even if it has a rule in beginning it still being triggered. last few days I figured method to make a trigger that won't trigger the script once delay has passed and it can be triggered by external script. unless the project mainly runs on onFrame then I think its better with a passive/active trigger like this one trigger: (enable==1 & (time<=new[count])) ? time : 0 will only trigger 1 time once time has hit the delayed time, once that happens it will move to next delay, and again only trigger 1 time once time has passed and so on. script: if (time>=new[count]) { 'action after delay, first delay will be 0' Monitor.value='action '+(count+1)+': '+floor( (time-old)*1000 )+ ' ms has passed';
count += 1; }
if (count == max) { 'do something when done' Pad.x=0; //Monitor.value=time; //(this was used to test if the trigger would still trigger after time has passed "new", and yes it only updates it the current time on next frame and no more) } example of defining the delay array: decl a; 'Writes the delay index'; for (a=0;a<max;a++) { new[a]=time+((delay/1000)*(a+1)); //(a+1) means first action will have a delay - "single event" //if u want first event to trigger instantly, use: (a+0) - "multi events" } count = 0; 'resets the counter for the delayed script'
enable = 1; 'once enable becomes 1 , the delayed_action script will start to trigger, because it are using a if rule as trigger then it wont run unless time is (under or =) the delay array created in new we could call this a (passive time trigger)' the delay array could easy be done different for delays between the event array. Try this standalone first : Attachment Deletedor just import this one into your own. Attachment Deleted
|
|