DoAfter
Script function

world.DoAfter

DOC_scripting Read about scripting

Type

Method

Summary

Adds a one-shot, temporary timer - simplified interface

Prototype

long DoAfter(double Seconds, BSTR SendText);

DOC_data_types View list of data type meanings


Description

This routine adds an unlabelled, temporary, one-shot timer, set to go off after the designated number of seconds. The first argument (seconds) must evaluate to a time between 0.1 second, and 23 hours 59 minutes 59 seconds (that is, 1 to 86,399).

From version 3.61 onwards of MUSHclient the interval may include fractions (ie. it is a floating-point number). This lets you set up sub-second intervals (eg. 0.5 seconds, 1.2 seconds).

To enable this you need to go to Global Configuration -> Timers and set the 'Timer Interval' in seconds to zero.

The maximum granularity of the timers is currently 0.1 seconds. In other words, regardless of what you specify, the timers are only checked every 10th of a second.

You can also use DoAfterSpeedWalk - this is the same as DoAfter, except the command is interpreted as a speedwalk sequence.

You can also use DoAfterNote - this is the same as DoAfter, except the text is sent to the output window, not the MUD.

The purpose of this is simplify the frequent case of simply wanting to do something in a few seconds, rather than using AddTimer.

WARNING - as DoAfter is implemented by using temporary MUSHclient timers, it will not work if timers are disabled. If DoAfter is not working for you (however the function call is returning zero) then ensure that timers are enabled in the Timers configuration dialog.



VBscript example

world.DoAfter 10, "eat food"
world.DoAfter 20.5, "get bottle bag"
world.DoAfter 21, "drink water"



Jscript example

world.DoAfter (10, "eat food");
world.DoAfter (20.5, "get bottle bag");
world.DoAfter (21, "drink water");



PerlScript example

$world->DoAfter (10, "eat food");
$world->DoAfter (20.5, "get bottle bag");
$world->DoAfter (21, "drink water");



Python example

world.DoAfter (10, "eat food")
world.DoAfter (20.5, "get bottle bag")
world.DoAfter (21, "drink water")



Lua example

DoAfter (10, "eat food")
DoAfter (20.5, "get bottle bag")
DoAfter (21, "drink water")



Return value

eTimeInvalid: The time is invalid (seconds not in range 0.1 to 86,399). 
eOK: added OK


DOC_errors View list of return code meanings


See Also ...

Topics

DOC_aliases Aliases
DOC_defaults Default triggers/aliases/timers/macros/colours
DOC_starting Getting started
DOC_group Groups
DOC_plugins Plugins
DOC_timers Timers
DOC_triggers Triggers

Functions

FNC_AddTimer AddTimer (Adds a timer)
FNC_DeleteTemporaryTimers DeleteTemporaryTimers (Deletes all temporary timers)
FNC_DeleteTimer DeleteTimer (Deletes a timer)
FNC_DeleteTimerGroup DeleteTimerGroup (Deletes a group of timers)
FNC_DoAfterNote DoAfterNote (Adds a one-shot, temporary note timer - simplified interface)
FNC_DoAfterSpecial DoAfterSpecial (Adds a one-shot, temporary, timer to carry out some special action)
FNC_DoAfterSpeedWalk DoAfterSpeedWalk (Adds a one-shot, temporary speedwalk timer - simplified interface)
FNC_EnableTimer EnableTimer (Enables or disables an timer)
FNC_EnableTimerGroup EnableTimerGroup (Enables/disables a group of timers)
FNC_GetTimer GetTimer (Gets details about a timer)
FNC_GetTimerInfo GetTimerInfo (Gets details about a timer)
FNC_GetTimerList GetTimerList (Gets the list of timers)
FNC_GetTimerOption GetTimerOption (Gets the value of a named timer option)
FNC_IsTimer IsTimer (Tests to see if a timer exists)
FNC_ResetTimer ResetTimer (Resets a named timer)
FNC_ResetTimers ResetTimers (Resets all timers)
FNC_SetTimerOption SetTimerOption (Sets the value of a named timer option)

(Help topic: function=DoAfter)

DOC_contents Documentation contents page