Register forum user name Search FAQ

DoAfterSpecial

Script function

world.DoAfterSpecial

Read about scripting

Type

Method

Summary

Adds a one-shot, temporary, timer to carry out some special action

Prototype

long DoAfterSpecial(long Seconds, BSTR SendText, short SendTo);

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 timer sends its "SendText" text to the designated location when it fires.

The first argument (seconds) must evaluate to a time between 0.1 second,
and 23 hours 59 minutes 59 seconds (that is, 0.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.

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

This lets you do things that involve simple scripting at some future time,
without having to go to a lot of trouble writing script routines.

The "SendTo" argument specifies where the text is to be sent to when the
time elapsed. It can be one of:

0: World
1: Command window
2: Output window
3: Status line
4: Notepad (new)
5: Notepad (append)
6: Log File
7: Notepad (replace)
8: Command queue
9: Send To Variable
10: Execute (re-parse as command)
11: Speedwalk (send text is speedwalk, queue it)
12: Script (send to script engine)
13: Immediate (send to world in front of speedwalk queue)
14: Script - after omit (send to script engine, after lines have been omitted)

The case "set variable" is not very useful because there is no way of specifying which variable,
however instead you could use "send to script" (12) and do a "setvariable". eg.

world.DoAfterSpecial 5, "SetVariable ""target"", ""kobold"" ", 12

This example uses double-quotes for the variable name and variable value, because they are quotes
within quotes (an argument to SetVariable inside the argument to DoAfterSpecial).

Also, case "Script - after omit" is really intended for use in triggers, and will have the same behaviour as "Script" if used elsewhere.

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


Available in MUSHclient version 3.35 onwards.



VBscript example

world.DoAfterSpecial 5, "EnableTriggerGroup ""mygroup"", 1", 12

In the above example the last argument (12) means send the 
command to the script engine after 5 seconds. 

The argument to EnableTriggerGroup has double quotes, 
because it is quotes within quotes.


world.DoAfterSpecial 10, "4s 3w", 11

In the above example the last argument (11) means send the command 
to the speed walk parser after 10 seconds.


Jscript example

world.DoAfterSpecial (5, "EnableTriggerGroup ("mygroup", 1);", 12);

In the above example the last argument (12) means send the 
command to the script engine after 5 seconds. 

The argument to EnableTriggerGroup has escaped quotes, 
because it is quotes within quotes.


world.DoAfterSpecial (10, "4s 3w", 11);


PerlScript example

$world->DoAfterSpecial (5, 'EnableTriggerGroup ("mygroup", 1);', 12);

In the above example the last argument (12) means send the 
command to the script engine after 5 seconds. 

We use single quotes for the argument to DoAfterSpecial, 
so we can use double quotes for the argument to EnableTriggerGroup.


$world->DoAfterSpecial (10, "4s 3w", 11);


Python example

world.DoAfterSpecial (5, "EnableTriggerGroup ("mygroup", 1)", 12)

In the above example the last argument (12) means send the 
command to the script engine after 5 seconds. 

The argument to EnableTriggerGroup has escaped quotes, 
because it is quotes within quotes.


world.DoAfterSpecial (10, "4s 3w", 11)


Lua example

DoAfterSpecial (5, 'EnableTriggerGroup ("mygroup", 1)', sendto.script)

--[[
In the above example the last argument (sendto.script) means send the 
command to the script engine after 5 seconds. 

The argument to EnableTriggerGroup has the alternative quotes, 
because it is quotes within quotes.
--]]


DoAfterSpecial (10, "4s 3w", sendto.speedwalk)


Lua notes

The "SendTo" field can be specified using the "sendto" table in the Lua global address space, as follows:

sendto.world = 0
sendto.command = 1
sendto.output = 2
sendto.status = 3
sendto.notepad = 4
sendto.notepadappend = 5
sendto.logfile = 6
sendto.notepadreplace = 7
sendto.commandqueue = 8
sendto.variable = 9
sendto.execute = 10
sendto.speedwalk = 11
sendto.script = 12
sendto.immediate = 13
sendto.scriptafteromit = 14


Return value

eTimeInvalid: The time is invalid (seconds not in range 0.1 to 86,399).
eOptionOutOfRange: The "SendTo" argument is not in the range 0 to 12.
eOK: added OK

View list of return code meanings

See Also ...

Topics

Aliases
Default triggers/aliases/timers/macros/colours
Getting started
Groups
Plugins
Timers
Triggers

Functions

(AddTimer) Adds a timer
(DeleteTemporaryTimers) Deletes all temporary timers
(DeleteTimer) Deletes a timer
(DeleteTimerGroup) Deletes a group of timers
(DoAfter) Adds a one-shot, temporary timer - simplified interface
(DoAfterNote) Adds a one-shot, temporary note timer - simplified interface
(DoAfterSpeedWalk) Adds a one-shot, temporary speedwalk timer - simplified interface
(EnableTimer) Enables or disables an timer
(EnableTimerGroup) Enables/disables a group of timers
(GetPluginTimerOption) Gets the value of a named timer option for a specified plugin
(GetPluginTriggerOption) Gets the value of a named trigger option for a specified plugin
(GetTimer) Gets details about a timer
(GetTimerInfo) Gets details about a timer
(GetTimerList) Gets the list of timers
(GetTimerOption) Gets the value of a named timer option
(IsTimer) Tests to see if a timer exists
(ResetTimer) Resets a named timer
(ResetTimers) Resets all timers
(SetTimerOption) Sets the value of a named timer option

(Help topic: function=DoAfterSpecial)

Documentation contents page


Search ...

Enter a search string to find matching documentation.

Search for:   

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.