To browser these website, it's necessary to store cookies on your computer.
The cookies contain no personal information, they are required for program control.
  the storage of cookies while browsing this website, on Login and Register.

Author Topic:  Timers  (Read 53 times)

0 Members and 1 Guest are viewing this topic.


« on: 19, May 2022, 12:12:46 »
Timers are useful mapping/scripting items when you want a script to be triggered after a set period of time (e.g. a player has dallied too long in a particular area and you want to eject them).

However, I have found little documentation on timers, and they seem notoriously difficult to program. I have had to glean stuff through trial and error, so I thought I would pass on what I have found. If others know more, please contribute!

If you look at the special tab of a timer's attributes in mapmaker, you will see the following:
(In spoiler tags as my description takes up a fair amount of space)
(click to show/hide)

These are the things I discovered, and which don't appear to be documented:
1. The timer will trigger the script twice, once when it starts, and once when it fires. When it starts, event.other contains a value. When it fires, event.other is nil. So your script should ignore a timer trigger unless event.other is nil.

2. A timer can be started by a connection to a switch (toggled by script), but not by a lever - this does not work!  The difference is that a switch is of type Handle and a lever is of tyoe Handle Trigger.

3. You would think you could start a timer from a script by not using a connection, and just setting timer.hitpoints to timer.max_hitpoints. Think again: the timer doesn't start.

4. However, if you want to stop the timer midway without a final trigger (for example, if your dallying player has left the restricted area voluntarily), you can set timer.hitpoints back to -1 and that works!

You obviously need to get the switch and timer objects by using beacons (or beacon if they are on the same map square). The easiest way is to have separate beacons on separate squares as you can then use beacon.environment - if on the same square you would have to iterate through map_objects to find both items.

The overall behaviour of timers is so weird, that I am sure I must have missed something. If anyone knows more - please add to this thread!


« Reply #1 on: 19, May 2022, 12:38:30 »
Just curious but would I be correct to assume that you could get a lever to trigger a switch that then triggers a timer
Doesn't matter, you'd die anyway. ;D Shroud's a hacker. After many hours of deep thought I have came to that conclusion.


« Reply #2 on: 19, May 2022, 15:42:20 »
Why stop there? Why not have a friendly  mob walk up to the lever and operate it?

In your scenario the lever would have to trigger a script which would then toggle the switch. I don't think all three things could have the same connection. Therein lies madness.


« Reply #3 on: 19, May 2022, 19:03:16 »
Great documentation, thanks! :)

I think in the future our "connection machines" ought to be simplified. The "handle vs handle trigger" is confusing, and the same issue exists with pedestals. Buttons have some quirky behaviours too. I think there are also altar triggers (sacrifice some specific item to trigger). Being unable to trigger a connection via script is also annoying.
-- _people_ :)


Related Topics

  Subject / Started by Replies Last post
6 Replies
Last post 09, August 2010, 22:31:36
by smacky