Name AddTimer
Type Method
Summary Adds a timer
Prototype long AddTimer(BSTR TimerName, short Hour, short Minute, short Second, BSTR ResponseText, long Flags, BSTR ScriptName);
Description Adds a timer to the list of timers.

You can use "DoAfter", "DoAfterNote" or "DoAfterSpeedWalk" for a simplified way of adding timers.

TimerName: name of this timer - may be empty
Hour: The hour to fire (0 - 23)
Minute: The minute to fire (0 - 59)
Second: The second to fire (0 - 59)
Response_text: what to send to the world
Flags: various flags, see list below
ScriptName: Which script subroutine to execute

Flags

The flags can be one or more of the constants below. For example, to enable the timer, and make it a one-shot, the flags would be 5. Preferably use the constant declarations in your script file, and "OR" them together. E.g.

VBscript: eEnabled or eOneShot
JScript: eEnabled | eOneShot


VBscript constants:

const eEnabled = 1 ' is timer enabled?
const eAtTime = 2 ' if not set, time is "every"
const eOneShot = 4 ' if set, timer only fires once
const eTimerSpeedWalk = 8 ' timer does a speed walk when it fires
const eTimerNote = 16 ' timer does a world.note when it fires
const eActiveWhenClosed = 32 ' timer fires even when world is disconnected
const eReplace = 1024 ' replace existing timer of same name
const eTemporary = 16384 ' temporary - do not save to world file


JScript constants:

var eEnabled = 1; // is timer enabled?
var eAtTime = 2; // if not set, time is "every"
var eOneShot = 4; // if set, timer only fires once
var eTimerSpeedWalk = 8; // timer does a speed walk when it fires
var eTimerNote = 16; // timer does a world.note when it fires
var eActiveWhenClosed = 32; // timer fires even when world is disconnected
var eReplace = 1024; // replace existing timer of same name
var eTemporary = 16384; // temporary - do not save to world file


PerlScript constants:

my $eEnabled = 1; # is timer enabled?
my $eAtTime = 2; # if not set, time is "every"
my $eOneShot = 4; # if set, timer only fires once
my $eTimerSpeedWalk = 8; # timer does a speed walk when it fires
my $eTimerNote = 16; # timer does a world.note when it fires
my $eActiveWhenClosed = 32; # timer fires even when world is disconnected
my $eReplace = 1024; # replace existing timer of same name
my $eTemporary = 16384; # temporary - do not save to world file
VBscript example
World.addtimer "my_timer", 0, 0, 1, "go north", 5, ""
Jscript example
world.addtimer("my_timer", 0, 0, 1, "go north", 5, "");
PerlScript example
$world->addtimer("my_timer", 0, 0, 1, "go north", 5, "");
Returns eInvalidObjectLabel: The timer name is not valid
eTimerAlreadyExists: A timer of that name already exists
eScriptNameNotLocated: The script name cannot be located in the script file
eTimeInvalid: The time is invalid (eg. hour not in range 0 to 23).
eOK: added OK

See also ...