Script syntax
Scripts are a series of blocks of the format
=Trigger,subject,[object]
*command;
*command;
etc...
Available script triggers
The first line of each block determines
when it is executed
The following triggers are available
Subject and object
The subject is used in conjunction with the
trigger to determine when the script is run.
e.g. 'takeobj, axe' - would be
triggered if the player took the axe.
The 'skill', and 'use' commands use both a subject and object
e.g.
'useobj,cow,bucket' - would trigger if you use the bucket with the cow.
e.g.
'skillnpc,orc,shockbolt' - would trigger when casting shockbolt on an orc.
The skills command can have just an object, but no subject
e.g.
'skillnpc,_,shockbolt' - would trigger when casting shockbolt on any npc.
Condition code
The * at the start of each command line is a
condition code.
The scripts use a single status flag which it set by lines
starting 'if'.
The condition code then remains the same until changed by
another if command
If the flag is true, then lines starting with a * or +
will be executed
If the flag is false, then lines starting with a * or - will
be executed
Misc commands
| thinkbubble(); | Should only be called if the player has just triggered a 'use' script. Displays a thinkbubble above the players head which contains the object they are currently using. For instance this is used to display the axe above your head when you chop a tree down. |
| ifmale(); | Test the player's gender, useful for getting gender specific language correct in the scripts. |
Control flow based
| Delay(delay); | Delays both the script and the player for the specified number of server cycles |
| Pause(mindelay, maxdelay); | Pauses the script for a random amount of time inbetween the specified minimum and maximum. The player is free to do other stuff meanwhile, useful for making trees regrow etc.. Be very careful when using delay or pause, as the player may have logged out meanwhile. Normally this doesn't matter, but don't rely on things after it to do anything permament which affects the player (such as setting a player variable) as it may be lost. |
| ifrandom(probability); | Randomly sets the condition flag to true or false. A probability of 0=impossible, and 256=certain |
| jump(labelname); | Jumps to the script block with the trigger 'Label,labelname' The other script will not return to this one |
| fork(labelname); | Starts the script block with trigger 'Label,labelname' running at the same time as this one! Be careful with this command :-) If the target block has no pause, wait, say, or npcsay commands then will behave like a gosub command. (due to non-preemptive multitasking) |
| end(); | Terminates processing of the current script block |
Chat based
| mes(string); | Displays the specified message at the bottom of the player screen |
| say(string); | Makes the players charactor say the specified string, all nearby people will also see this. The command will then automatically delay the script for a time depending on the users text speed settings. |
| qsay(string); | Makes the players charactor say the specified string, with no delay |
| multi2(string, label, string, label); | Displays a multiple choice menu with 2 items, depending which the players chooses the relevant block of script will be called. Note: The player may decide not to choose either item in which case the script terminates |
| multi3(string, label, string, label, string, label); | Displays a multiple choice menu with 3 items |
| multi4(string, label, string, label, string, label, string, label); | Displays a multiple choice menu with 4 items |
Movement based
| changelevel(int level); | Moves the player to the specified level, without changing the x and y position. Level-codes: 0=ground floor, 1=1st floor, 2=2nd floor, 3=basement |
| changelevelup(); | Moves the player up one level if possible. |
| changeleveldown(); | Moves the player down one level if possible. |
other player based
| These commands are only useful when 2 players are interacting with each other. They are typically used when the 1st player uses a spell on another player, and they allow the 2nd players stats to modified and tested | |
| addplaystat(stat, constant, percent); | Temporarily adds constant+(current*percent)/100 to the 2nd players specified stat. Where current is the current level of the stat |
| subplaystat(stat, constant, percent); | Like addplaystat, except it subtracts. |
| healplaystat(stat, constant, percent); | Like addplaystat, but won't take the players stat above the normal level |
| ifplaystatup(stat); | Sets the condition to true if the 2nd players stat is currently above the normal level, false otherwise |
| ifplaystatdown(stat) | Sets the condition to true if the 2nd players stat is currently below the normal level, false otherwise |
| omes(string); | Displays a message on the 2nd players screen |
| ifplayervisible(); | Sets the condition code to true if a line of sight can be traced between the 2 players |
| shootplayer(projectile); | Fires a projectile at the 2nd player |
stat based
| ifstatrandom(stat, base-probability, top-probability); | Like the random command but stat modified, if the stat is 0 the base-probability is used, if the stat is 100 the top-probability is used. If the stat is inbetween then the 2 values are interpolated. |
| advancestat(stat, base, exp); | Permanently increases the specified stat, and sets the new levels as the current normal. The equation used is: stat+=base+exp*stat; |
| addstat(stat, constant, percent); | Temporarily adds constant+(current*percent)/100 to the 2nd players specified stat. Where current is the current level of the stat |
| substat(stat, constant, percent); | Like addstat, except it subtracts. |
| healstat(stat, constant, percent); | Like addstat, but won't take the players stat above the normal level |
| ifstatup(stat) | Sets the condition to true if the players stat is currently above the normal level, false otherwise |
| ifstatdown(stat) | Sets the condition to true if the players stat is currently below the normal level, false otherwise |
Object based
| give(object, count); | Gives the specified number of the specified object to players inventory |
| remove(object, count); | Removes the specified number of the specified object from players inventory (or as many as possible) |
| ifworn(object); | Sets condition flag to true if player is wearing specified object |
| ifheld(object, count); | Sets condition flag to true if player is holding specified object |
| addobject(coordinate, object, count); | Adds object to the ground. The coordinate can only be worked out with the aid of the runescape map editor. |
Location based
Boundary based
Npc based
Variable based