Author Topic: [Tutorial] How to Make a Delayed Action  (Read 6442 times)

Psyborg

  • Posts: 23
  • Maggot Crusher.
    • View Profile
[Tutorial] How to Make a Delayed Action
« on: August 21, 2013, 10:59:54 PM »
I was wondering how to make an action that would be delayed after the initial trigger is activated. This is important for tasks that may have a time limit. It is also may be necessary in certain cases to create frame animations. So here is how to do that:

In this case, we are playing a delayed sound after a trigger is hit.



A- This is the AreaTrigger I used for a RectangleArea (not shown).

B- A ToggleElement node, which is activated by the AreaTrigger (CTRL-ALT) and performs it's action (ENABLE) on C (Button-linked)

C- A TimerTrigger, which (and this is important) is DISABLED initially. The ToggleElement will enable the TimerTrigger, which begins its timer.

Set the frequency for the initial delay, and you may have it repeat as many times as you want, but it will not start until the initial trigger (i.e. AreaTrigger) is activated.

D- The action that the TimerTrigger activates (CTRL-ALT) once it is enabled by the ToggleElement. In this case, a sound is played shortly after the AreaTrigger is activated. This action can be anything, or even another long script.
« Last Edit: August 21, 2013, 11:09:07 PM by Psyborg »

monev

  • Posts: 3
  • Maggot Crusher.
    • View Profile
Re: [Tutorial] How to Make a Delayed Action
« Reply #1 on: August 22, 2013, 12:33:28 AM »
You can also use that to make timed animations with the use of counters.

as an example: I started with a corridor with torches that are off. and I want them to turn on in sequence when the player passes the gate>


once the player crosses the area object, it triggers the enabling of the timer trigger (which started with its "enabled" box unchecked) the Timer Trigger goes off 4 times, once every 1000 milliseconds (yes the timer is in milliseconds)

the timer is connected to 4 counter scripts. each counter script is set to a different number biased on the order I want them to "become true". The way counters work is, they keep track of how many times they are triggered by something (anything) but wont play the linked script until a minimum number of times triggered ("count") is met. after that point it will trigger they next script every time itself  is triggered. So if you don't want the things the counter is linked to to happen more then once after the minimum is met, you need to set the "trigger times" to the same number as the desired "count".

in this image the counters are linked to: The destruction of the original lamp_off objects, spawning of lamp objects, playing of lamp sound.


Linaru

  • Moderator
  • Posts: 113
  • That Collectable coin is mine!
    • View Profile
Re: [Tutorial] How to Make a Delayed Action
« Reply #2 on: August 24, 2013, 12:05:23 PM »
or you could use the delay box. :P

ont he right script pane there is a drop down box all scripts have that show a list of links to other scripts. what ever you pick in that drop down boxshould be highlighted. the text box next to it with a 0 in is a delay.



usually i put a 300 tick delay between a button being pressed and the object the button interacts with. thats what hipshot used for his buttons anyway.

-----------------------------------------------------------
Stabaddey Stabaddey Zap
-----------------------------------------------------------

KptnKook

  • Posts: 45
  • Immersive or DIE!!!!!
    • View Profile
Re: [Tutorial] How to Make a Delayed Action
« Reply #3 on: August 31, 2013, 06:27:58 PM »
what about resetting a counter?


if i want to have a loop, how can i manage to reset the counters back to zero?
« Last Edit: August 31, 2013, 06:39:36 PM by KptnKook »

Psyborg

  • Posts: 23
  • Maggot Crusher.
    • View Profile
Re: [Tutorial] How to Make a Delayed Action
« Reply #4 on: September 02, 2013, 05:26:03 AM »
I swear I never saw a delay box in my editor....different versions maybe? I've seen a lot of times people talk about stuff that seems like they're talking about a different version of the game...

Keefachu

  • Posts: 18
  • Yakisooobaaaa!
    • View Profile
Re: [Tutorial] How to Make a Delayed Action
« Reply #5 on: September 05, 2013, 03:33:01 AM »
Thanks for the tutorial! I'm trying to learn the stuff of making a map, so this will come in handy!