How to Script
- This article is incomplete, which means that while it is not a stub, it still lacks certain data or information.
- Not done yet
- Please see Category:Incomplete articles for more articles that are incomplete.
Read This First Unless you are playing in The Fallen, scripting while unresponsive, regardless of your status at the keyboard, is against the rules. It is your responsibility to create scripts that will not continue endlessly, in case you fall asleep or have to leave the keyboard suddenly. |
The Basics
The section will cover the most basic tools for scripting in the eScape and StormFront FEs.
Important Notes
- Empty space before a command is ignored.
- Empty lines are ignored.
- If the end of the script is reached, the script exits.
- All commands are case insensitive, though variables are not.
- Only one command can be put on a line.
Simple Commands
- PUT <string>: This will cause the script to enter the string as if you typed it into the game and hit enter.
- MOVE <string>: This will do the same thing as PUT, but will then pause the script until a new room is entered.
- WAIT: This command will pause the script until a prompt is received. It is not affected by suppressing prompts in game.
- WAITFOR <string>: This will pause the script until it sees the string.
- NEXTROOM: This will cause the script to wait until you enter a new room.
- PAUSE <#>: This will pause the script for the indicated number of seconds.
- SAVE: This command is obsolete and will not be covered.
- EXIT: This will end the script
Labels
Labels are basically like signposts that you can cause the script to jump to. The most common way to cause a script to switch to a label is using "GOTO <label>" although MATCH/MATCHRE is another way.
A label is placed but putting a word on it's own line, followed by a colon, such as
thisIsALabel:
An important thing to note about them is that they are not case sensitive. "Label" is the same as "label" is the same as "lAbEl".
Matches
The combined use of MATCH, MATCHRE and MATCHWAIT are essential tools for the majority of intermediate and advanced scripts.
The MATCH command is executed with two parts, the label and the match string, in the form of "MATCH <label> <string>". If the <string> is found, the script will immedately jump to the specified label.
Here's an example pulled from a real script:
1 putAway: 2 MATCH putAway ...wait 3 MATCH cycle Stow what? 4 MATCH cycle You are already wearing that. 5 MATCH cycle But that is already in your inventory. 6 MATCH cycle You 7 PUT stow my pickle 8 MATCHWAIT
The combination of lines one and two illustrate the most common use for for MATCH. If the game pops up "...wait x seconds" when you attempt a command, it will cycle back to the label on line one and attempt it again.
Lines 3-6 watch for the various outcomes of the command on 7, and will jump to the specified label upon detecting them. The fact that the label is the same regardless of the outcome is not important since any number of labels can be mixed.
Lastly, line 8 is a special command that tells the script "wait here until a match is found". This can either be desirable, such as if you're waiting for the barge and don't want to do anything till it shows up, or can be undesirable, such as when your action produces a result you didn't put in a MATCH for and will wait forever.
Variables
Variables are basically storage locations for words. They allow you to imput information in one place and retreive it at another. They are refered to using the syntax "%<variable name>" such as "%target" or "%person". Note: Unlike labels, variables are case sensitive; "variable" is NOT the same as "Variable" or "vArIaBlE".
There are two main types of variables, and one special one.
Command Line Variables
The first type is called a command line variable. When you start your script using the ".<scriptname>" method, after the name you can input up to 9 other words for storage. Example:
.kill him andHim andHimToo her monkey randomGuy
These are then able to be accessed by the script. They are accessed using %1 through %9, which unfortunately cannot be changed once the script is started, with a few exceptions.
The major exception is the SHIFT command. Upon encountering SHIFT, %1 is deleted, and the rest is shifted down one, with %2 now being %1, %3 being %2, all the way to %9 which is now empty. Note that "%0" is the same as putting "%1 %2 %3 %4 %5" .... "%9", listing out all the command line variables.
How are these useful? Perhaps you wish to write a script that picks and disarms a box for you, however your box can be a crate, a strongbox, a box or even a coffer. Using %1 in the proper place, you can run your script with ".pick coffer" and it will target your coffer for opening.
Note: These variables are deleted if the script ends for any reason.
Standard Variables
These variables are a different sort, because they can both be accessed from within the script and because they will remain after the script ends. However, unlike command line variables, they can only be altered by a script or through the Variables panel. Like all variables, they take the form of "%<variable name>".
There are two major script commands for interacting with standard variables. The first is SETVARIABLE, which uses the syntax "SETVARIABLE <variable name without the %> <variable contents>" such as "SETVARIABLE weapon sword". One thing to realize is that you can set a variable to nothing, by using "SETVARIABLE <variable name>", which can be useful in some advanced scripting.
The second way to interact with them is using DELETEVARIABLE, which does what you'd expect: it removes the variable and it's contents.
It is important to distinguish between an empty variable and a deleted variable. An empty variable when you call it, simply adds a blank space, but a deleted variable will insert the variable name when called. Example:
Command:
- PUT pick coffer %way
Empty:
- Result: pick coffer
- This will end up picking your coffer normally
Deleted:
- Result: pick coffer %way
- This will end up with the game telling you it has no idea what a "coffer %way" is.
Counter Variable
See the section on COUNTER for more details.