How to Script: Difference between revisions
(added warning) |
No edit summary |
||
Line 20: | Line 20: | ||
===Simple Commands=== |
===Simple Commands=== |
||
* # : Used for commenting, any line that begins with the number symbol is ignored by the script. |
|||
* PUT ''<string>'': This will cause the script to enter the string as if you typed it into the game and hit enter. |
* 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. |
* 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. |
* 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. |
* WAITFOR ''<string>'': This will pause the script until it sees the string. |
||
* WAITFORRE ''<string>'': Same as WAITFOR but allows the use of Regular Expressions. See the advanced section for more details. |
|||
* NEXTROOM: This will cause the script to wait until you enter a new room. |
* 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. |
* PAUSE ''<#>'': This will pause the script for the indicated number of seconds. |
||
* SAVE: This command is obsolete and will not be covered. |
* SAVE: This command is obsolete and will not be covered. |
||
* EXIT: This will end the script |
* EXIT: This will end the script. |
||
===Labels=== |
===Labels=== |
||
Line 35: | Line 37: | ||
<pre>thisIsALabel:</pre> |
<pre>thisIsALabel:</pre> |
||
Labels are not case sensitive, so "Label" is the same as "label" is the same as "lAbEl". |
|||
===Matches=== |
===Matches=== |
||
The combined use of MATCH, MATCHRE and MATCHWAIT are essential tools for the majority of intermediate and advanced scripts. |
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. |
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: |
Here's an example pulled from a real script: |
||
Line 57: | Line 59: | ||
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. |
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. |
||
MATCHRE allows use of Regular Expressions in the search string. See the advanced section for details on regular expressions. |
|||
===Variables=== |
===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". |
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. |
There are two main types of variables, and one special one. |
||
====Command Line Variables==== |
====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: |
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: |
||
<pre> .kill him andHim andHimToo her monkey randomGuy</pre> |
<pre> .kill him andHim andHimToo her monkey randomGuy</pre> |
||
These are then able to be accessed by the script. They are accessed using % |
These are then able to be accessed by the script. They are accessed using "%0" through "%9", with "%1" being the first word after the script name, "%2" being the second, etc. Note that "%0" is the same as putting "%1 %2 %3 %4 %5" .... "%9", listing out all the command line variables. |
||
Unfortunately, command line variables cannot be changed once the script is started, with a few exceptions, the major one being SHIFT. 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. |
|||
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. |
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. |
Note: These variables are deleted if the script ends for any reason. |
||
Line 79: | Line 83: | ||
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>". |
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. |
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. |
The second way to interact with them is using DELETEVARIABLE, which does what you'd expect: it removes the variable and it's contents. |
||
Line 94: | Line 98: | ||
'''Deleted:''' |
'''Deleted:''' |
||
: Result: pick coffer %way |
: Result: pick coffer %way |
||
::This will |
::This will result in the game telling you it cannot find your "coffer %way". |
||
====Counter Variable==== |
====Counter Variable==== |
||
See the section on COUNTER for more details. |
There is a variable that is exclusively used for the COUNTER commands, "%c". See the section on COUNTER for more details. |
Revision as of 22:37, 10 April 2009
- 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
- # : Used for commenting, any line that begins with the number symbol is ignored by the script.
- 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.
- WAITFORRE <string>: Same as WAITFOR but allows the use of Regular Expressions. See the advanced section for more details.
- 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:
Labels are not case sensitive, so "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.
MATCHRE allows use of Regular Expressions in the search string. See the advanced section for details on regular expressions.
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 "%0" through "%9", with "%1" being the first word after the script name, "%2" being the second, etc. Note that "%0" is the same as putting "%1 %2 %3 %4 %5" .... "%9", listing out all the command line variables.
Unfortunately, command line variables cannot be changed once the script is started, with a few exceptions, the major one being SHIFT. 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.
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 result in the game telling you it cannot find your "coffer %way".
Counter Variable
There is a variable that is exclusively used for the COUNTER commands, "%c". See the section on COUNTER for more details.