Lich scripting reference: Difference between revisions

From Elanthipedia
Jump to navigation Jump to search
(replace use of {{log}} with preformatted text markup)
(Adding a lead and intro)
Line 1: Line 1:
{{RTOC}}
{{RTOC}}

== put ==
[[The Lich]] scripting engine allows you to automate many of your
put "look"
routine tasks through scripts. Lich scripts are written in
[http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], so you have
some powerful Ruby features available, such as
[http://ruby-gnome2.sourceforge.jp/ GTK bindings] to create GUIs.

If you are more comfortable with StormFront and Wizard scripts, Lich can run
most of them unaltered, but since Lich is running them, you can have any number
of them running simultaneously. Lich is highly compatible with
StormFront/Wizard scripts, so you can use your existing scripts and scripting
experience when writing Lich scripts.

==Running a Script==
By preceding your script name with the prefix character, which defaults to a
semicolon <code>;</code> character, you can run a script. For example, if you
created a script named ''sell-loot'' then issuing the command
<code>;sell-loot</code> would run the ''sell-loot'' script.

===Passing Variables to Scripts===
You can also supply arguments to the script by adding the arguments after the
script name. A script can act on these arguments or use them to modify the
behavior.

<pre style="overflow:hidden;">
;sell-loot gems
</pre>

This will run the ''sell-loot'' script with <code>variable[1]</code> set to
"gems".

<pre style="overflow:hidden;">
;sell-loot gems skins
</pre>

This will run the ''sell-loot'' script with <code>variable[1]</code> set to
"gems" and <code>variable[2]</code> set to "skins". Sometimes you want to use
spaces in your arguments, so you can use quotes:

<pre style="overflow:hidden;">
;sell-loot "a fancy gem" skins
</pre>

This will set <code>variable[1]</code> to "a fancy gem" and
<code>variable[2]</code> to "skins".

==Stopping a Script==
A script ends when it reaches the last command or encounters the
<code>exit</code> command. A script can be killed with the <code>;kill</code>
command.

==Labels and the Goto Command==
A label is a spot in the code where a command can branch to with certain
commands. They are given unique names followed by a colon. For example:

<pre style="overflow:hidden;">
loop:
move n
goto "loop"
</pre>

This script contains one label named <code>loop</code>. As written, this script
will continually move north until it is killed by the user e.g. via
<code>;kill</code>. Because of the goto loop, it will never end on its own.

A script label can be any string of characters, so long as it does not have a
space. Each label must be unique in a script. You cannot have two labels with
the same name. For the purposes of matching labels, case is ignored. Therefore
"Bob" is the same as "bob" is the same as "BOB" etc.

There is a special catch-all label <code>labelError</code>. If a script command
tries to branch to a label that is not found, the script will abort with an
error unless there is a <code>labelError:</code> label. If the label exists, it
will branch this catch-all label.

Label names can be constructed from variables in commands such as
<code>goto</code>. For example:

<pre style="overflow:hidden;">
goto "label" + variable[1]

label1:
echo "The first variable was 1"
exit

label2:
echo "The first variable was 2"
exit

label3:
echo "The first variable was 3"
exit
</pre>

==Commands==
===put===
<pre style="overflow:hidden;">
put "look"
</pre>
*'''Returns:''' the string that was sent
*'''Returns:''' the string that was sent
*'''Description:''' Identical to Wizard.
*'''Description:''' Identical to Wizard.


== fput ==
===fput===
<pre style="overflow:hidden;">
fput "stance defensive"
fput "stance defensive", "are now in a defensive stance", "can't do that while dead", "etc"
fput "stance defensive"
fput "stance defensive", "are now in a defensive stance", "can't do that while dead", "etc"
</pre>
*'''Returns:''' the string that was accepted as meaning the action succeeded (see below)
*'''Returns:''' the string that was accepted as meaning the action succeeded (see below)
*'''Synonyms:''' forceput
*'''Synonyms:''' forceput
*'''Description:''' It's named 'forceput' because originally it was intended to be used only infrequently, but as it's turned out there are very few times when 'put' is preferable. This command will continue to 'put' whatever string you give it, until it receives a line from the game that it doesn't recognize as one of the common "command rejected" responses (for example, "You can't do that while entangled in a web", "...wait x seconds" (RT), "Wait x seconds." (cast RT), "Sorry, you may only type ahead x lines", "You'll have to stand up first" (stands and reattempts), etc). If stunned, it will wait until you're no longer stunned to reattempt; if in RT (hard or soft), will wait 'x' seconds before reattempting. If you need to stand, it will do so and retry immediately. If it causes a type ahead error, it will pause for 1 second and then reattempt. This has a very high rate of success, but it is definitely not infallible -- it only checks the next line received from the game, and there's no guarantee the next line from the game has anything at all to do with what the 'fput' command just sent. Because of this it can often fail to realize the command wasn't really successful, particularly if the user is doing a lot of things at once. If given more than one string, the first string is taken as the command to send to the game, and all other strings are used as what to accept as meaning the action succeeded. BE CAREFUL with this behavior! It can very infrequently be extremely useful, but if not used cautiously, it can easily cause a script to mistakenly repeat an action many times in *very* rapid succession (which with CoL signs for instance can very easily kill you in less than a second flat).
*'''Description:''' It's named 'forceput' because originally it was intended to be used only infrequently, but as it's turned out there are very few times when 'put' is preferable. This command will continue to 'put' whatever string you give it, until it receives a line from the game that it doesn't recognize as one of the common "command rejected" responses (for example, "You can't do that while entangled in a web", "...wait x seconds" (RT), "Wait x seconds." (cast RT), "Sorry, you may only type ahead x lines", "You'll have to stand up first" (stands and reattempts), etc). If stunned, it will wait until you're no longer stunned to reattempt; if in RT (hard or soft), will wait 'x' seconds before reattempting. If you need to stand, it will do so and retry immediately. If it causes a type ahead error, it will pause for 1 second and then reattempt. This has a very high rate of success, but it is definitely not infallible -- it only checks the next line received from the game, and there's no guarantee the next line from the game has anything at all to do with what the 'fput' command just sent. Because of this it can often fail to realize the command wasn't really successful, particularly if the user is doing a lot of things at once. If given more than one string, the first string is taken as the command to send to the game, and all other strings are used as what to accept as meaning the action succeeded. BE CAREFUL with this behavior! It can very infrequently be extremely useful, but if not used cautiously, it can easily cause a script to mistakenly repeat an action many times in *very* rapid succession (which with CoL signs for instance can very easily kill you in less than a second flat).


== pause ==
===pause===
<pre style="overflow:hidden;">
pause 1
pause '2s'
pause 1
pause '2s'
pause '3m'
pause '3m'
pause '2h'
pause '2h'
pause '1d'
pause '1d'
</pre>
*'''Returns:''' an integer
*'''Returns:''' an integer
*'''Description:''' If given no arguments, pauses for one second. If given an integer, pauses for that many seconds. If given a string (as in the examples above), extracts the number to pause for from the string and pauses for that many seconds/hours/days (yeah, well, I was bored, so why not make it do days too). Return value is the number of seconds it paused for.
*'''Description:''' If given no arguments, pauses for one second. If given an integer, pauses for that many seconds. If given a string (as in the examples above), extracts the number to pause for from the string and pauses for that many seconds/hours/days (yeah, well, I was bored, so why not make it do days too). Return value is the number of seconds it paused for.


== echo ==
===echo===
<pre style="overflow:hidden;">
echo "Hi there!"
echo "Hi there!"
echo "Line one", "Line two", "endlessly"
echo "Line one", "Line two", "endlessly"
</pre>
*'''Returns:''' a string
*'''Returns:''' a string
*'''Description:''' Displays '[script_name: the string it was given]' in the game window; if given multiple strings it echoes each string on its own line. If it's given no arguments, it simply prints a blank line without the '[script_name: ]' business.
*'''Description:''' Displays '[script_name: the string it was given]' in the game window; if given multiple strings it echoes each string on its own line. If it's given no arguments, it simply prints a blank line without the '[script_name: ]' business.


== respond ==
===respond===
<pre style="overflow:hidden;">
respond
respond
respond "I'm a string to display"
respond "I'm a string to display"
respond "Line one", "Line two", "so on and so on"
respond "Line one", "Line two", "so on and so on"
</pre>
*'''Returns:''' integer
*'''Returns:''' integer
*'''Description:''' Just like the 'echo' command, but does not display the script name. Since it's possible for Lich to be running two dozen scripts at the same time, it can get a little hard to know which script is saying what unless they use the 'echo' command and not the 'respond' command. Still, 'echo' can be a bit ugly for printing tables and whatnot, so use this instead if desired. The return value is how many characters the last string displayed contained.
*'''Description:''' Just like the 'echo' command, but does not display the script name. Since it's possible for Lich to be running two dozen scripts at the same time, it can get a little hard to know which script is saying what unless they use the 'echo' command and not the 'respond' command. Still, 'echo' can be a bit ugly for printing tables and whatnot, so use this instead if desired. The return value is how many characters the last string displayed contained.


== goto ==
===goto===
<pre style="overflow:hidden;">
goto "MainLabel"
goto "MainLabel"
</pre>
*'''Returns:''' (has no return value, the current execution stack is discarded and the jump never returns)
*'''Returns:''' (has no return value, the current execution stack is discarded and the jump never returns)
*'''Description:''' Identical to standard Wizard/SF scripts; the label to jump to has to be in quotes, and its case insensitive. The label declaration itself (the LABEL: line) MUST NOT be in quotes: only the name of the label when you use the goto command. If a label called "main" and a label called "Main" (with a capital) both exist, then using GOTO to jump to the "main" label would jump there -- however, if you tried to jump to the "Main" label, it would jump to the capital-letter one instead (basically if there are two labels with the same name but different capitalizations, the goto command starts acting as though its case sensitive).
*'''Description:''' Identical to standard Wizard/SF scripts; the label to jump to has to be in quotes, and its case insensitive. The label declaration itself (the LABEL: line) MUST NOT be in quotes: only the name of the label when you use the goto command. If a label called "main" and a label called "Main" (with a capital) both exist, then using goto to jump to the "main" label would jump there -- however, if you tried to jump to the "Main" label, it would jump to the capital-letter one instead (basically if there are two labels with the same name but different capitalization, the goto command starts acting as though its case sensitive).


== wait ==
===wait===
<pre style="overflow:hidden;">
wait
wait
</pre>
*'''Returns:''' a string
*'''Returns:''' a string
*'''Description:''' Identical to Wizard; waits until a line from the game is seen. Returns the line (in actuality this command simply clears the game stack and executes a 'get').
*'''Description:''' Identical to Wizard; waits until a line from the game is seen. Returns the line (in actuality this command simply clears the game stack and executes a 'get').


== waitrt ==
===waitrt===
<pre style="overflow:hidden;">
waitrt
waitrt
</pre>
*'''Returns:''' an integer (Fixnum class)
*'''Returns:''' an integer (Fixnum class)
*'''Description:''' Pauses for however many seconds you're currently in roundtime for. Return value is how many seconds paused. Waits until you're in roundtime if you aren't at the time this command is used, and therefore can hang endlessly.
*'''Description:''' Pauses for however many seconds you're currently in roundtime for. Return value is how many seconds paused. Waits until you're in roundtime if you aren't at the time this command is used, and therefore can hang endlessly.


== waitrt? ==
===waitrt?===
<pre style="overflow:hidden;">
waitrt?
waitrt?
</pre>
*'''Returns:''' an integer (Fixnum class)
*'''Returns:''' an integer (Fixnum class)
*'''Description:''' Identical to 'waitrt', but does not wait until you're in roundtime and as such will not hang (but will not wait for any roundtime if the game hasn't sent that you're in roundtime yet).
*'''Description:''' Identical to 'waitrt', but does not wait until you're in roundtime and as such will not hang (but will not wait for any roundtime if the game hasn't sent that you're in roundtime yet).


== waitcastrt ==
===waitcastrt===
<pre style="overflow:hidden;">
waitcastrt
waitcastrt
</pre>
*'''Returns:''' an integer (Fixnum class)
*'''Returns:''' an integer (Fixnum class)
*'''Description:''' Pauses for however many seconds you're currently in RT for. Return value is how many seconds paused. Waits until you're in RT if you aren't at the time this command is used, and therefore can hang endlessly.
*'''Description:''' Pauses for however many seconds you're currently in RT for. Return value is how many seconds paused. Waits until you're in RT if you aren't at the time this command is used, and therefore can hang endlessly.


== waitcastrt? ==
===waitcastrt?===
<pre style="overflow:hidden;">
waitcastrt?
waitcastrt?
</pre>
*'''Returns:''' an integer (Fixnum class)
*'''Returns:''' an integer (Fixnum class)
*'''Description:''' Identical to 'waitcastrt', but does not wait until you're in cast roundtime and as such will not hang (but will not wait for any cast roundtime if the game hasn't sent that you're in cast roundtime yet).
*'''Description:''' Identical to 'waitcastrt', but does not wait until you're in cast roundtime and as such will not hang (but will not wait for any cast roundtime if the game hasn't sent that you're in cast roundtime yet).


== waitfor ==
===waitfor===
<pre style="overflow:hidden;">
waitfor " just arrived.", "More lines to waitfor if you desire", "endlessly"
waitfor " just arrived.", "More lines to waitfor if you desire", "endlessly"
</pre>
*'''Returns:''' a string
*'''Returns:''' a string
*'''Description:''' Waits until a line from the game includes the string you gave it as an argument. The return value is the complete string from the game (in the example used here, if Shaelun entered the room, the command would return "Shaelun just arrived."). 'waitfor' is case insensitive (capital letters are considered matches even if the string it was given didn't have a capital letter there).
*'''Description:''' Waits until a line from the game includes the string you gave it as an argument. The return value is the complete string from the game (in the example used here, if Shaelun entered the room, the command would return "Shaelun just arrived."). 'waitfor' is case insensitive (capital letters are considered matches even if the string it was given didn't have a capital letter there).


== unique_waitfor ==
===unique_waitfor===
<pre style="overflow:hidden;">
unique_waitfor "continue"
unique_waitfor "continue"
</pre>
*'''Returns:''' a string
*'''Returns:''' a string
*'''Description:''' Same as 'waitfor' but acts on the 'unique' queue.
*'''Description:''' Same as 'waitfor' but acts on the 'unique' queue.


== wait_while ==
===wait_while===
<pre style="overflow:hidden;">
wait_while { percenthealth != 100 }
wait_while { percenthealth != 100 }
wait_while "You do not have full health: waiting until you do." { percenthealth != 100 }
wait_while "You do not have full health: waiting until you do." { percenthealth != 100 }
</pre>
*'''Returns:''' true/false
*'''Returns:''' true/false
*'''Synonyms:''' all the variants of `Wounds.(bodypart)' are the same for `Scars.(bodypart)'
*'''Synonyms:''' all the variants of `Wounds.(bodypart)' are the same for `Scars.(bodypart)'
*'''Description:''' The script will wait while the given code block has a logical value of 'true', and will only continue on to the next line when/if the code block has a value of 'false'. If given the optional string to announce to the user, it will only display that string if it's going to be sitting there waiting for something -- if the command will not be waiting at all, it doesn't display the string to the user. Note that there's no limit to how long/complicated the code block can be; it was designed for very short logical comparisons like the example above, but need not be used that way.
*'''Description:''' The script will wait while the given code block has a logical value of 'true', and will only continue on to the next line when/if the code block has a value of 'false'. If given the optional string to announce to the user, it will only display that string if it's going to be sitting there waiting for something -- if the command will not be waiting at all, it doesn't display the string to the user. Note that there's no limit to how long/complicated the code block can be; it was designed for very short logical comparisons like the example above, but need not be used that way.


== wait_until ==
===wait_until===
<pre style="overflow:hidden;">
wait_until { checkmana(50) }
wait_until { checkmana(50) }
</pre>
*'''Returns:''' true/false
*'''Returns:''' true/false
*'''Description:''' Identical in all ways to 'wait_while', but does the opposite (waits UNTIL the given code block is true, not WHILE it's true). Also takes the optional string if desired.
*'''Description:''' Identical in all ways to 'wait_while', but does the opposite (waits UNTIL the given code block is true, not WHILE it's true). Also takes the optional string if desired.


== upstream_get ==
===upstream_get===
<pre style="overflow:hidden;">
upstream_get
upstream_get
</pre>
*'''Returns:''' a string
*'''Returns:''' a string
*'''Description:''' Same thing as "get" except it fetches the last line the user sent to the game. A script has to ask Lich to give it this information by first using the "toggle_upstream" command.
*'''Description:''' Same thing as "get" except it fetches the last line the user sent to the game. A script has to ask Lich to give it this information by first using the "toggle_upstream" command.


== toggle_upstream ==
===toggle_upstream===
<pre style="overflow:hidden;">
toggle_upstream
toggle_upstream
</pre>
*'''Returns:''' updated value of the "upstream" flag (true/false)
*'''Returns:''' updated value of the "upstream" flag (true/false)
*'''Description:''' See above.
*'''Description:''' See above.


== upstream_waitfor ==
===upstream_waitfor===
<pre style="overflow:hidden;">
upstream_waitfor "climb stairs"
upstream_waitfor "climb stairs"
</pre>
*'''Returns:''' a string
*'''Returns:''' a string
*'''Description:''' Identical to "waitfor" but only checks the upstream commands (the commands sent to the game by the user).
*'''Description:''' Identical to "waitfor" but only checks the upstream commands (the commands sent to the game by the user).


== undo_before_dying ==
===undo_before_dying===
<pre style="overflow:hidden;">
undo_before_dying
undo_before_dying
</pre>
*'''Returns:''' nothing useful
*'''Returns:''' nothing useful
*'''Description:''' Clears any "before_dying" code blocks that have been used. If none have been used, does nothing (see the 'before_dying' command).
*'''Description:''' Clears any "before_dying" code blocks that have been used. If none have been used, does nothing (see the 'before_dying' command).


== abort! ==
===abort!===
<pre style="overflow:hidden;">
abort!
abort!
</pre>
*'''Returns:''' never returns
*'''Returns:''' never returns
*'''Description:''' Immediately kills the script, bypassing any 'before_dying' blocks that have been registered. Probably won't ever be of use, but it's a way to make the calling script go away as fast as possible (note that it isn't any faster than the 'exit' command is, it just makes sure that nothing except stopping the script happens).
*'''Description:''' Immediately kills the script, bypassing any 'before_dying' blocks that have been registered. Probably won't ever be of use, but it's a way to make the calling script go away as fast as possible (note that it isn't any faster than the 'exit' command is, it just makes sure that nothing except stopping the script happens).


== watchhealth ==
===watchhealth===
<pre style="overflow:hidden;">
watchhealth(50) { echo "Uh, your health is below 50..." }
watchhealth(50) { echo "Uh, your health is below 50..." }
watchhealth(50, proc_object)
watchhealth(50, proc_object)
</pre>
*'''Returns:''' nothing useful
*'''Returns:''' nothing useful
*'''Description:''' Returns immediately so that the calling script continues to run as normal, and while it does, monitors your health. If it falls below the number you give it, executes the block you passed to it. Only does this once -- if you want it to repeat as the script executes (be careful, chances are your health will still be below 50 after the block executes once) then pass watchhealth a proc object that includes a line registering itself over again (as in, a proc that includes a 'watchhealth(#, self)' thingie). If your health never falls below the number you give it, then nothing happens; once the script ends, it stops watching.
*'''Description:''' Returns immediately so that the calling script continues to run as normal, and while it does, monitors your health. If it falls below the number you give it, executes the block you passed to it. Only does this once -- if you want it to repeat as the script executes (be careful, chances are your health will still be below 50 after the block executes once) then pass watchhealth a proc object that includes a line registering itself over again (as in, a proc that includes a 'watchhealth(#, self)' thingie). If your health never falls below the number you give it, then nothing happens; once the script ends, it stops watching.


== checkoutside ==
===checkoutside===
<pre style="overflow:hidden;">
checkoutside
checkoutside
outside?
outside?
</pre>
*'''Returns:''' true/false
*'''Returns:''' true/false
*'''Synonyms:''' outside?
*'''Synonyms:''' outside?
*'''Description:''' Really simple, just returns true if you're outside, false if you aren't. Probably only of use to rangers writing their own spellup scripts or something, but either way: it's available if you have a use for it.
*'''Description:''' Really simple, just returns true if you're outside, false if you aren't. Probably only of use to rangers writing their own spellup scripts or something, but either way: it's available if you have a use for it.


== Settings.load ==
===Settings.load===
<pre style="overflow:hidden;">
Settings.load
Settings.load
Settings["SettingName"]
Settings["SettingName"]
Settings.save
Settings.save
Settings.clear
Settings.clear
</pre>
*'''Returns:''' either a hash representing your settings, or 'nil' if no settings for the script exist
*'''Returns:''' either a hash representing your settings, or 'nil' if no settings for the script exist
*'''Description:''' Note that Settings.clear will erase all settings, but it will NOT save that on its own. Issue a Settings.save command after the Settings.clear if you want that script's settings reset permanently.
*'''Description:''' Note that Settings.clear will erase all settings, but it will NOT save that on its own. Issue a Settings.save command after the Settings.clear if you want that script's settings reset permanently.


== toggle_unique ==
===toggle_unique===
<pre style="overflow:hidden;">
toggle_unique
toggle_unique
</pre>
*'''Returns:''' updated value of the 'unique' setting (true or false)
*'''Returns:''' updated value of the 'unique' setting (true or false)
*'''Description:''' When a script is set as being 'unique', it does not receive normal game data; instead it only receives what the user sends to it by typing ;send to (script) (message). This is of use if a script wants to only act on a user's input or has no use for game data (it provides a method for scripts to make sure game data doesn't accidentally get recognized as a user's input, and also serves to prevent scripts from slowly eating away at system resources because the script never checks or clears its data buffer -- see the 'clear' command for more on that).
*'''Description:''' When a script is set as being 'unique', it does not receive normal game data; instead it only receives what the user sends to it by typing ;send to (script) (message). This is of use if a script wants to only act on a user's input or has no use for game data (it provides a method for scripts to make sure game data doesn't accidentally get recognized as a user's input, and also serves to prevent scripts from slowly eating away at system resources because the script never checks or clears its data buffer -- see the 'clear' command for more on that).


== no_kill_all ==
===no_kill_all===
<pre style="overflow:hidden;">
no_kill_all
no_kill_all
</pre>
*'''Returns:''' updated value of the 'no_kill_all' setting (true or false)
*'''Returns:''' updated value of the 'no_kill_all' setting (true or false)
*'''Description:''' Toggles on/off the 'no kill all' setting: when this setting is on (defaults to off), a script will not be effected by the user typing ;kill all. A script with this set to on must be killed specifically (by typing ;kill [script], or just ;kill). There is no way to prevent a script from being killed when targetted by the user.
*'''Description:''' Toggles on/off the 'no kill all' setting: when this setting is on (defaults to off), a script will not be effected by the user typing ;kill all. A script with this set to on must be killed specifically (by typing ;kill [script], or just ;kill). There is no way to prevent a script from being killed when targeted by the user.


== silence_me ==
===silence_me===
<pre style="overflow:hidden;">
silence_me
silence_me
</pre>
*'''Returns:''' new value of the 'silenced' setting (true or false)
*'''Returns:''' new value of the 'silenced' setting (true or false)
*'''Description:''' Toggles on/off the 'silenced' setting. A script with this on will not have commands it sends to the game echoed to your game window. A script run in SAFE mode cannot change this setting (attempting to do so will generate a warning and otherwise have no effect).
*'''Description:''' Toggles on/off the 'silenced' setting. A script with this on will not have commands it sends to the game echoed to your game window. A script run in SAFE mode cannot change this setting (attempting to do so will generate a warning and otherwise have no effect).


== toggle_echo ==
===toggle_echo===
<pre style="overflow:hidden;">
toggle_echo
toggle_echo
</pre>
*'''Returns:''' new value of the 'suppress echo' setting (true or false)
*'''Returns:''' new value of the 'suppress echo' setting (true or false)
*'''Description:''' Toggles on/off the 'suppress echo' setting. A script with this on will not execute any 'echo' commands, but will silently ignore them instead; it's designed more for people who don't want clutter in their game window but still want to make use of an existing script. Commands sent to the game are still echoed to the game window.
*'''Description:''' Toggles on/off the 'suppress echo' setting. A script with this on will not execute any 'echo' commands, but will silently ignore them instead; it's designed more for people who don't want clutter in their game window but still want to make use of an existing script. Commands sent to the game are still echoed to the game window.


== checkpoison ==
===checkpoison===
<pre style="overflow:hidden;">
checkpoison
checkpoison
</pre>
*'''Returns:''' true/false
*'''Returns:''' true/false
*'''Description:''' See checkdisease.
*'''Description:''' See checkdisease.


== checkdisease ==
===checkdisease===
<pre style="overflow:hidden;">
checkdisease
checkdisease
</pre>
*'''Returns:''' true/false
*'''Returns:''' true/false
*'''Description:''' See checkpoison.
*'''Description:''' See checkpoison.


== get ==
===get===
<pre style="overflow:hidden;">
get
get
</pre>
*'''Returns:''' a string
*'''Returns:''' a string
*'''Description:''' Fetches the next un-checked line of game data (while a script is running, it is given every game line, and these lines are available for a script to check/use at its leisure).
*'''Description:''' Fetches the next un-checked line of game data (while a script is running, it is given every game line, and these lines are available for a script to check/use at its leisure).


== unique_get ==
===unique_get===
<pre style="overflow:hidden;">
unique_get
unique_get
</pre>
*'''Returns:''' a string
*'''Returns:''' a string
*'''Description:''' Fetches a line from the unique stack, as opposed to the game data stack (see 'toggle_unique' for more about what the 'unique' stack refers to).
*'''Description:''' Fetches a line from the unique stack, as opposed to the game data stack (see 'toggle_unique' for more about what the 'unique' stack refers to).


== send_to_script ==
===send_to_script===
<pre style="overflow:hidden;">
send_to_script 'scriptname', 'message to send'
send_to_script 'scriptname', 'message to send'
</pre>
*'''Returns:''' true or false
*'''Returns:''' true or false
*'''Description:''' The target script will be sent a string exactly as though it came from the game. Returns true if successful, false if the script wasn't found to be active.
*'''Description:''' The target script will be sent a string exactly as though it came from the game. Returns true if successful, false if the script wasn't found to be active.


== unique_send_to_script ==
===unique_send_to_script===
<pre style="overflow:hidden;">
unique_send_to_script 'scriptname', 'message to send'
unique_send_to_script 'scriptname', 'message to send'
</pre>
*'''Returns:''' true or false
*'''Returns:''' true or false
*'''Description:''' Same as 'send_to_script', but the script will receive the string sent in its 'unique' stack instead of its 'game data' stack (see 'toggle_unique' for more info).
*'''Description:''' Same as 'send_to_script', but the script will receive the string sent in its 'unique' stack instead of its 'game data' stack (see 'toggle_unique' for more info).


== move ==
===move===
<pre style="overflow:hidden;">
move 'northwest'
move 'northwest'
</pre>
*'''Returns:''' true or false
*'''Returns:''' true or false
*'''Description:''' Same as the Wizard 'move' command, but it will usually compensate for things like type ahead errors, RT, currently stunned, etc.; will also stand and re-attempt the movement if it's detected to be necessary. Returns 'true' if the move was executed properly, 'false' if it wasn't able to be performed (which is very rare due to the move command's error compensation measures).
*'''Description:''' Same as the Wizard 'move' command, but it will usually compensate for things like type ahead errors, RT, currently stunned, etc.; will also stand and re-attempt the movement if it's detected to be necessary. Returns 'true' if the move was executed properly, 'false' if it wasn't able to be performed (which is very rare due to the move command's error compensation measures).


== multimove ==
===multimove===
<pre style="overflow:hidden;">
multimove 'nw', 'ne', 'go hole', 'climb stairs'
multimove 'nw', 'ne', 'go hole', 'climb stairs'
</pre>
*'''Returns:''' true or false
*'''Returns:''' true or false
*'''Description:''' Takes multiple directions to move in and executes the 'move' command for each one. Returns the value of the last 'move' command executed (true or false).
*'''Description:''' Takes multiple directions to move in and executes the 'move' command for each one. Returns the value of the last 'move' command executed (true or false).


== fetchloot ==
===fetchloot===
<pre style="overflow:hidden;">
fetchloot
fetchloot
</pre>
*'''Returns:''' a string
*'''Returns:''' a string
*'''Description:''' Performs a 'look' and takes/puts away all items on the ground that aren't listed in your 'excludeloot:' setting. Return value is the last line from the game.
*'''Description:''' Performs a 'look' and takes/puts away all items on the ground that aren't listed in your 'excludeloot:' setting. Return value is the last line from the game.


== Lich.fetchloot ==
===Lich.fetchloot===
<pre style="overflow:hidden;">
Lich.fetchloot
Lich.fetchloot
</pre>
*'''Returns:''' a string
*'''Returns:''' a string
*'''Description:''' Identical to 'fetchloot' in all ways except only the items listed in your 'treasure:' setting are fetched.
*'''Description:''' Identical to 'fetchloot' in all ways except only the items listed in your 'treasure:' setting are fetched.


== checkloot ==
===checkloot===
<pre style="overflow:hidden;">
checkloot
checkloot
</pre>
*'''Returns:''' an array of strings (or an empty array if no items)
*'''Returns:''' an array of strings (or an empty array if no items)
*'''Description:''' Returns an array consisting of the items currently in the room.
*'''Description:''' Returns an array consisting of the items currently in the room.


== take ==
===take===
<pre style="overflow:hidden;">
take "box", "coffer", "ruby", "etc"
take "box", "coffer", "ruby", "etc"
</pre>
*'''Returns:''' a string (the last line the 'fput' command saw)
*'''Returns:''' a string (the last line the 'fput' command saw)
*'''Description:''' Picks up every item listed and puts each one in turn into your 'lootsack:' setting by issuing the commands with fput.
*'''Description:''' Picks up every item listed and puts each one in turn into your 'lootsack:' setting by issuing the commands with fput.


== checkpaths ==
===checkpaths===
<pre style="overflow:hidden;">
checkpaths
checkpaths
checkpaths 'nw'
checkpaths 'nw'
</pre>
*'''Returns:''' an array of strings, or true/false
*'''Returns:''' an array of strings, or true/false
*'''Description:''' Returns an array consisting of the current 'Obvious exits:' directions if given no argument, or true/false based on whether all arguments given are currently available as exits or not.
*'''Description:''' Returns an array consisting of the current 'Obvious exits:' directions if given no argument, or true/false based on whether all arguments given are currently available as exits or not.


== walk ==
===walk===
<pre style="overflow:hidden;">
walk
walk
</pre>
*'''Returns:''' true or false
*'''Returns:''' true or false
*'''Description:''' Moves in a random cardinal direction (what's seen in the 'Obvious exits:' line), storing the direction moved, and returning 'true' if there is a critter in the room or 'false' if there aren't any NPCs in the room. The stored direction will not be among the random directions chosen the next time the 'walk' command is used (unless it hits a dead-end, then it will backtrack the way it came).
*'''Description:''' Moves in a random cardinal direction (what's seen in the 'Obvious exits:' line), storing the direction moved, and returning 'true' if there is a critter in the room or 'false' if there aren't any NPCs in the room. The stored direction will not be among the random directions chosen the next time the 'walk' command is used (unless it hits a dead-end, then it will backtrack the way it came).


== run ==
===run===
<pre style="overflow:hidden;">
run if not health(50)
run if not health(50)
</pre>
*'''Returns:''' true or false
*'''Returns:''' true or false
*'''Description:''' Will execute a 'walk' command repeatedly until it enters a room with no critters, at which point it returns and the script will pick up execution on the next line (does not continue to run away).
*'''Description:''' Will execute a 'walk' command repeatedly until it enters a room with no critters, at which point it returns and the script will pick up execution on the next line (does not continue to run away).


== checkfried ==
===checkfried===
<pre style="overflow:hidden;">
checkfried
checkfried
</pre>
*'''Returns:''' true or false
*'''Returns:''' true or false
*'''Description:''' Returns true if you're fried, false if not.
*'''Description:''' Returns true if you're fried, false if not.


== checkmind ==
===checkmind===
<pre style="overflow:hidden;">
checkmind
checkmind
checkmind(2)
checkmind(2)
</pre>
*'''Returns:''' true or false, or a string
*'''Returns:''' true or false, or a string
*'''Description:''' By itself returns a string representing the level of exp in your head ('clear as a bell', 'fried', 'muddled', etc). If given an integer, returns true or false if you have the corresponding level of exp in your head.
*'''Description:''' By itself returns a string representing the level of exp in your head ('clear as a bell', 'fried', 'muddled', etc). If given an integer, returns true or false if you have the corresponding level of exp in your head.


== percentmind ==
===percentmind===
<pre style="overflow:hidden;">
percentmind
percentmind
percentmind(80)
percentmind(80)
</pre>
*'''Returns:''' integer, or true or false
*'''Returns:''' integer, or true or false
*'''Description:''' By itself returns an integer ranging from 0-100 representing the percentage of exp in your head. If given an integer, returns true or false if you have at least that percentage of experience. Both saturated and fried show up as 100 percent - a user interested in distinguishing between the two can add a checksaturated or saturated? qualifier to their percentmind check.
*'''Description:''' By itself returns an integer ranging from 0-100 representing the percentage of exp in your head. If given an integer, returns true or false if you have at least that percentage of experience. Both saturated and fried show up as 100 percent - a user interested in distinguishing between the two can add a checksaturated or saturated? qualifier to their percentmind check.


== checkarea ==
===checkarea===
<pre style="overflow:hidden;">
checkarea
checkarea
checkarea "illistim"
checkarea "illistim"
</pre>
*'''Returns:''' a string, or true or false
*'''Returns:''' a string, or true or false
*'''Description:''' By itself returns the geographical area of your current room, or if given a string to check for, returns true or false based on whether your current area matches the string or not.
*'''Description:''' By itself returns the geographical area of your current room, or if given a string to check for, returns true or false based on whether your current area matches the string or not.


== checkroom ==
===checkroom===
<pre style="overflow:hidden;">
checkroom
checkroom
checkroom "table"
checkroom "table"
</pre>
*'''Returns:''' true or false, or a string
*'''Returns:''' true or false, or a string
*'''Description:''' Identical to checkarea, but uses the room title instead of the geographical area.
*'''Description:''' Identical to checkarea, but uses the room title instead of the geographical area.


== checkfamarea/checkfamroom ==
===checkfamarea/checkfamroom===
<pre style="overflow:hidden;">
checkfamarea
checkfamarea
checkfamarea "illistim"
checkfamarea "illistim"
</pre>
*'''Returns:''' a string, or true/false
*'''Returns:''' a string, or true/false
*'''Description:''' Identical to checkarea/checkroom, but check your familiar's current location instead of yours (only in Wizard and only if you have a familiar).
*'''Description:''' Identical to checkarea/checkroom, but check your familiar's current location instead of yours (only in Wizard and only if you have a familiar).


== checkright/checkleft ==
===checkright/checkleft===
<pre style="overflow:hidden;">
checkright
checkright
checkleft "broadsword"
checkleft "broadsword"
</pre>
*'''Returns:''' true or false, or a string
*'''Returns:''' true or false, or a string
*'''Synonyms:''' righthand?/lefthand?
*'''Synonyms:''' righthand?/lefthand?
*'''Description:''' Give them a string and will return true/false if it matches what you're holding, or the last word in the item name if used by itself. If your hands are currently empty, it will return 'nil' (identical to 'false' in a logical comparison) regardless of whether it was given an argument or not. This behavior can be useful to make absolutely certain a 'take' command succeeded, for instance.
*'''Description:''' Give them a string and will return true/false if it matches what you're holding, or the last word in the item name if used by itself. If your hands are currently empty, it will return 'nil' (identical to 'false' in a logical comparison) regardless of whether it was given an argument or not. This behavior can be useful to make absolutely certain a 'take' command succeeded, for instance.


== check(thing) ==
===check(thing)===
<pre style="overflow:hidden;">
checkstanding
checkstanding
checkspell "spirit defense"
checkspell "spirit defense"
checkdead
checkdead
</pre>
*'''Returns:''' mostly true/false
*'''Returns:''' mostly true/false
*'''Synonyms:''' checkstanding; checknotstanding; checksitting; checkprone; checkkneeling/kneeling?; checkprep/prepped?; checkmind; checkgrouped/checkjoined/joined?; checkwebbed/webbed?; checkstunned/stunned?; checkdead/dead?; checkhidden/checkhiding/hidden/hiding?; checkname/myname?; checkspell/checkactive/active?
*'''Synonyms:''' checkstanding; checknotstanding; checksitting; checkprone; checkkneeling/kneeling?; checkprep/prepped?; checkmind; checkgrouped/checkjoined/joined?; checkwebbed/webbed?; checkstunned/stunned?; checkdead/dead?; checkhidden/checkhiding/hidden/hiding?; checkname/myname?; checkspell/checkactive/active?
*'''Description:''' Most are true if you are (checkstunned for example), false if you aren't; they all follow the same basic behavior as the above-documented 'check' commands.
*'''Description:''' Most are true if you are (checkstunned for example), false if you aren't; they all follow the same basic behavior as the above-documented 'check' commands.


== checkname ==
===checkname===
<pre style="overflow:hidden;">
checkname
checkname
checkname "Shaelun"
checkname "Shaelun"
</pre>
*'''Returns:''' string or true/false
*'''Returns:''' string or true/false
*'''Description:''' True/false if given a string and the names match, or just returns the character name if given no arguments.
*'''Description:''' True/false if given a string and the names match, or just returns the character name if given no arguments.


== checknpcs ==
===checknpcs===
<pre style="overflow:hidden;">
if checknpcs
if checknpcs
fput "attack"
fput "attack"
end
end
Line 294: Line 492:
put "greet #{npc}"
put "greet #{npc}"
end
end
</pre>
*'''Returns:''' an array of strings, a string, or nil
*'''Returns:''' an array of strings, a string, or nil
*'''Description:''' If checknpcs is used without giving it npcs to check for, it returns an array of strings coresponding to the noun of each npc in the room, or nil if there are no npcs (does not return an empty array, so you can use "if checknpcs"). If chekcnpcs is given npcs to look for, it returns a string of the first matching npc it finds, or nil if none matched (any string evaluates to true, only nil and false evaluate to false in an if statement).
*'''Description:''' If checknpcs is used without giving it npcs to check for, it returns an array of strings corresponding to the noun of each npc in the room, or nil if there are no npcs (does not return an empty array, so you can use "if checknpcs"). If chekcnpcs is given npcs to look for, it returns a string of the first matching npc it finds, or nil if none matched (any string evaluates to true, only nil and false evaluate to false in an if statement).


== checkpcs ==
===checkpcs===
<pre style="overflow:hidden;">
checkpcs
checkpcs
checkpcs "shaelun"
checkpcs "shaelun"
</pre>
*'''Returns:''' array of strings, or true/false
*'''Returns:''' array of strings, or true/false
*'''Description:''' Identical to 'checknpcs', but with the players currently present.
*'''Description:''' Identical to 'checknpcs', but with the players currently present.


== checkfampcs ==
===checkfampcs===
<pre style="overflow:hidden;">
checkfampcs "shaelun"
checkfampcs "shaelun"
checkfampcs
checkfampcs
</pre>
*'''Returns:''' array of strings, or true/false
*'''Returns:''' array of strings, or true/false
*'''Synonyms:''' checkfamnpcs
*'''Synonyms:''' checkfamnpcs
*'''Description:''' Identical to the above two, but tracks for your familiar's room instead. Not available in SF as of v3.06.
*'''Description:''' Identical to the above two, but tracks for your familiar's room instead. Not available in SF as of v3.06.


== checkstamina ==
===checkstamina===
<pre style="overflow:hidden;">
checkstamina 50
checkstamina 50
checkstamina
checkstamina
</pre>
*'''Returns:''' true/false or an integer
*'''Returns:''' true/false or an integer
*'''Description:''' Only in StormFront (there is no auto-updated stamina tag in Wizard). Given no arguments, returns your current stamina. Given a number, returns true/false based on whether you have at least or more than that number.
*'''Description:''' Only in StormFront (there is no auto-updated stamina tag in Wizard). Given no arguments, returns your current stamina. Given a number, returns true/false based on whether you have at least or more than that number.


== checkmana/checkhealth/checkspirit ==
===checkmana/checkhealth/checkspirit===
<pre style="overflow:hidden;">
checkmana 50
checkmana 50
</pre>
*'''Returns:''' identical as above
*'''Returns:''' identical as above
*'''Synonyms:''' health, health?, mana, mana?, spirit, spirit?
*'''Synonyms:''' health, health?, mana, mana?, spirit, spirit?
*'''Description:''' Identical to checkstamina.
*'''Description:''' Identical to checkstamina.


== clear ==
===clear===
<pre style="overflow:hidden;">
clear
clear
</pre>
*'''Returns:''' an array of strings (possible for the return array to be empty, but unlikely)
*'''Returns:''' an array of strings (possible for the return array to be empty, but unlikely)
*'''Description:''' Empties ALL unchecked input to the script from ALL queues (normal game stack, unique script stack and upstream stack); the return value is whatever was in the game data stack before it was cleared (which could be nothing, in which case the return is an empty array).
*'''Description:''' Empties ALL unchecked input to the script from ALL queues (normal game stack, unique script stack and upstream stack); the return value is whatever was in the game data stack before it was cleared (which could be nothing, in which case the return is an empty array).


== i_stand_alone ==
===i_stand_alone===
<pre style="overflow:hidden;">
i_stand_alone
i_stand_alone
</pre>
*'''Returns:''' updated value of the setting (true/false)
*'''Returns:''' updated value of the setting (true/false)
*'''Description:''' Toggles on/off. Removes a script from ALL data feeds; a script using this will receive no game lines and no unique data whatsoever (unless they toggle it back off). If Lich can more or less ignore that a script exists and not bother with keeping its data stacks up-to-the-second with game data and anything else it's requested, then a script has virtually no overhead whatsoever (meaning any resources it requires come only from what it does independantly). Useful for some scripts who have no need to eat up resources being fed game data (such as dict.lic).
*'''Description:''' Toggles on/off. Removes a script from ALL data feeds; a script using this will receive no game lines and no unique data whatsoever (unless they toggle it back off). If Lich can more or less ignore that a script exists and not bother with keeping its data stacks up-to-the-second with game data and anything else it's requested, then a script has virtually no overhead whatsoever (meaning any resources it requires come only from what it does independently). Useful for some scripts who have no need to eat up resources being fed game data (such as dict.lic).


== matchtimeout ==
===matchtimeout===
<pre style="overflow:hidden;">
matchtimeout 5, "string to watch for", "another", "endlessly"
matchtimeout 5, "string to watch for", "another", "endlessly"
</pre>
*'''Returns:''' a string, or false
*'''Returns:''' a string, or false
*'''Description:''' Same as 'waitfor', but if a match isn't seen in the given amount of time, returns a value of 'false' and the script will move on.
*'''Description:''' Same as 'waitfor', but if a match isn't seen in the given amount of time, returns a value of 'false' and the script will move on.


== matchwait ==
===matchwait===
*'''Returns:''' a string
*'''Returns:''' a string
*'''Description:''' If used without any arguments, 100% identical to Wizard 'matchwait' commands. You can optionally give it arguments, in which case it acts identically to 'waitfor' in all ways except one: matches are case sensitive (for instance, matchwait "shaelun" will not match if the word "Shaelun" is seen from the game).
*'''Description:''' If used without any arguments, 100% identical to Wizard 'matchwait' commands. You can optionally give it arguments, in which case it acts identically to 'waitfor' in all ways except one: matches are case sensitive (for instance, matchwait "shaelun" will not match if the word "Shaelun" is seen from the game).


== match ==
===match===
<pre style="overflow:hidden;">
match 'label', 'line to watch for'
match 'label', 'line to watch for'
match "gameline", "gameline", "some other gameline", "so on and so forth"
match "gameline", "gameline", "some other gameline", "so on and so forth"
</pre>
*'''Returns:''' a string
*'''Returns:''' a string
*'''Description:''' If given exactly two arguments, identical to the Wizard 'match' command. If given *any* other number of arguments, it's a case sensitive version of 'waitfor' but instead of returning the entire matching game line, it returns only the portion of the string you asked it to watch for.
*'''Description:''' If given exactly two arguments, identical to the Wizard 'match' command. If given *any* other number of arguments, it's a case sensitive version of 'waitfor' but instead of returning the entire matching game line, it returns only the portion of the string you asked it to watch for.


== matchfind ==
===matchfind===
<pre style="overflow:hidden;">
matchfind "A ? attacks you!", "A ? swings a ? at you!"
matchfind "A ? attacks you!", "A ? swings a ? at you!"
person, weapon = matchfind "? swings a ? at you!"
person, weapon = matchfind "? swings a ? at you!"
</pre>
*'''Returns:''' a string or an array
*'''Returns:''' a string or an array
*'''Description:''' Same as 'waitfor', but returns only the portion of the line where the question mark(s) are. If given multiple question marks, returns an array containing the portions of the string (in order). Note that if you assign multiple variables to equal a single array, the array's elements are used in order and assigned to each variable (if there are fewer elements in the array than there are variables being assigned, variables receive a value of 'nil', and if there are more elements in the array than there are variables being assigned, the last variable is assigned an array with the remaining values). This is why the above usage example works (person, weapon =).
*'''Description:''' Same as 'waitfor', but returns only the portion of the line where the question mark(s) are. If given multiple question marks, returns an array containing the portions of the string (in order). Note that if you assign multiple variables to equal a single array, the array's elements are used in order and assigned to each variable (if there are fewer elements in the array than there are variables being assigned, variables receive a value of 'nil', and if there are more elements in the array than there are variables being assigned, the last variable is assigned an array with the remaining values). This is why the above usage example works (person, weapon =).


== matchfindword ==
===matchfindword===
<pre style="overflow:hidden;">
weapon = matchfindword "Shaelun swings a ? at you!"
weapon = matchfindword "Shaelun swings a ? at you!"
</pre>
*'''Returns:''' a string (single word)
*'''Returns:''' a string (single word)
*'''Description:''' Identical to 'matchfind', but only looks for a single word where the question marks are. Note that a line won't match if more than one word is where the question mark is (in the above example, if the weapon were a "broadsword" it would match, but if it were a "sonic hammer of kai" there would be no match).
*'''Description:''' Identical to 'matchfind', but only looks for a single word where the question marks are. Note that a line won't match if more than one word is where the question mark is (in the above example, if the weapon were a "broadsword" it would match, but if it were a "sonic hammer of kai" there would be no match).


== matchfindexact ==
===matchfindexact===
<pre style="overflow:hidden;">
matchfindexact "? just arrived."
matchfindexact "? just arrived."
</pre>
*'''Returns:''' a string
*'''Returns:''' a string
*'''Description:''' Version of matchfind meant for use in special cases; matchfind is very forgiving and will return and match anything (case insensitively) -- matchfindexact is very strict. It is case sensitive and cares about things like spaces, word boundaries (partial pieces of a word will not match, only whole words), the case of the string it's looking for, etc.. Use it if you need to use matchfind and want to make sure only a very specific line matches.
*'''Description:''' Version of matchfind meant for use in special cases; matchfind is very forgiving and will return and match anything (case insensitively) -- matchfindexact is very strict. It is case sensitive and cares about things like spaces, word boundaries (partial pieces of a word will not match, only whole words), the case of the string it's looking for, etc.. Use it if you need to use matchfind and want to make sure only a very specific line matches.


== send_scripts ==
===send_scripts===
<pre style="overflow:hidden;">
send_scripts "To the running scripts, this line looks identical to one that came from the game"
send_scripts "To the running scripts, this line looks identical to one that came from the game"
</pre>
*'''Returns:''' true/false
*'''Returns:''' true/false
*'''Description:''' Same as 'send_to_script', but sends a line to all scripts instead of just one.
*'''Description:''' Same as 'send_to_script', but sends a line to all scripts instead of just one.


== regetall ==
===regetall===
<pre style="overflow:hidden;">
regetall "Shaelun"
regetall "Shaelun"
</pre>
*'''Returns:''' an array of strings, or nil
*'''Returns:''' an array of strings, or nil
*'''Description:''' Takes a string and returns an array of all game lines (since login) that match as having contained the given string (absolutely every single line since you logged in, Lich remembers them all). If a script is set as receiving the status data that doesn't show in the game window, those lines are also matched for; if the script is only being fed normal game data, that's the only history this command checks. If no matching lines were found, returns 'nil' (which is false in a logical comparison). As well as returning the matches, it also adds them to the script's game data stack so that subsequent 'get' commands will fetch them in order. The string to match for is actually optional, and if omitted, all lines are considered 'matching'.
*'''Description:''' Takes a string and returns an array of all game lines (since login) that match as having contained the given string (absolutely every single line since you logged in, Lich remembers them all). If a script is set as receiving the status data that doesn't show in the game window, those lines are also matched for; if the script is only being fed normal game data, that's the only history this command checks. If no matching lines were found, returns 'nil' (which is false in a logical comparison). As well as returning the matches, it also adds them to the script's game data stack so that subsequent 'get' commands will fetch them in order. The string to match for is actually optional, and if omitted, all lines are considered 'matching'.


== reget ==
===reget===
<pre style="overflow:hidden;">
reget 3
reget 3
reget 5, "Shaelun"
reget 5, "Shaelun"
</pre>
*'''Returns:''' an array of strings, or nil
*'''Returns:''' an array of strings, or nil
*'''Description:''' Similar to 'regetall' in behavior, but it only checks the current RAM cache (every 2 minutes, Lich's 'memory' of game data is emptied out of RAM and stored in a temporary file on the hard disk so that the program doesn't take up more resources than is necessary -- these files are deleted when the program closes); it also takes an optional integer, which represents how many game lines back to check ('reget 5' would scan the last 5 lines from the game that are still in RAM). If the integer is omitted, will scan the entire existing RAM buffer (again, cleared every 2 minutes).
*'''Description:''' Similar to 'regetall' in behavior, but it only checks the current RAM cache (every 2 minutes, Lich's 'memory' of game data is emptied out of RAM and stored in a temporary file on the hard disk so that the program doesn't take up more resources than is necessary -- these files are deleted when the program closes); it also takes an optional integer, which represents how many game lines back to check ('reget 5' would scan the last 5 lines from the game that are still in RAM). If the integer is omitted, will scan the entire existing RAM buffer (again, cleared every 2 minutes).


== multifput ==
===multifput===
<pre style="overflow:hidden;">
multifput "stance offensive", "incant 910", "stance defensive"
multifput "stance offensive", "incant 910", "stance defensive"
</pre>
*'''Returns:''' a string (return value of the last 'fput' executed)
*'''Returns:''' a string (return value of the last 'fput' executed)
*'''Description:''' Takes multiple strings and executes an 'fput' command for every one sequentially.
*'''Description:''' Takes multiple strings and executes an 'fput' command for every one sequentially.


== kill_script ==
===kill_script===
<pre style="overflow:hidden;">
kill_script "test"
kill_script "test"
</pre>
*'''Returns:''' true/false
*'''Returns:''' true/false
*'''Synonyms:''' kill_scripts, stop_script, stop_scripts
*'''Synonyms:''' kill_scripts, stop_script, stop_scripts
*'''Description:''' Simulates the user having entered ;kill test in the game entry box and hitting enter; takes multiple scripts to kill. If the script is not running, returns false; if the script was found to be active and was killed, returns true.
*'''Description:''' Simulates the user having entered ;kill test in the game entry box and hitting enter; takes multiple scripts to kill. If the script is not running, returns false; if the script was found to be active and was killed, returns true.


== start_script ==
===start_script===
<pre style="overflow:hidden;">
start_script "test"
start_script "test"
start_script "heal", [ "shaelun", "adhara" ]
start_script "heal", [ "shaelun", "adhara" ]
</pre>
*'''Returns:''' true/false
*'''Returns:''' true/false
*'''Description:''' Simulates the user having entered ;test in the game entry box. Returns 'true' if the script was successfully started, 'false' if for any reason it couldn't be found/started. The optional second argument (which must be an array, as seen in the above example) can be used to simulate arguments to the script (the above example would simulate the user typing: ;heal shaelun adhara).
*'''Description:''' Simulates the user having entered ;test in the game entry box. Returns 'true' if the script was successfully started, 'false' if for any reason it couldn't be found/started. The optional second argument (which must be an array, as seen in the above example) can be used to simulate arguments to the script (the above example would simulate the user typing: ;heal shaelun adhara).


== start_scripts ==
===start_scripts===
<pre style="overflow:hidden;">
start_scripts "test"
start_scripts "test"
start_scripts "test", "calcredux", "etc"
start_scripts "test", "calcredux", "etc"
</pre>
*'''Returns:''' true/false
*'''Returns:''' true/false
*'''Description:''' Executes a "start_script" command for every argument given. Note that you cannot give a script arguments when using this command.
*'''Description:''' Executes a "start_script" command for every argument given. Note that you cannot give a script arguments when using this command.


== start_wizard_script ==
===start_wizard_script===
<pre style="overflow:hidden;">
start_wizard_script "test", [ "command line variable(s)", "etc" ]
start_wizard_script "test", [ "command line variable(s)", "etc" ]
</pre>
*'''Returns:''' true if successful, false if the script can't be found or run
*'''Returns:''' true if successful, false if the script can't be found or run
*'''Description:''' Same as 'start_script', but starts Wizard/SF script files.
*'''Description:''' Same as 'start_script', but starts Wizard/SF script files.


== maxhealth/maxstamina/maxmana/maxspirit ==
===maxhealth/maxstamina/maxmana/maxspirit===
<pre style="overflow:hidden;">
fput "eat my acantha leaf" while (checkhealth < maxhealth)
fput "eat my acantha leaf" while (checkhealth < maxhealth)
</pre>
*'''Returns:''' integer
*'''Returns:''' integer
*'''Description:''' Returns your maximum health/spirit/stamina/mana as an integer (class Fixnum). Takes no arguments.
*'''Description:''' Returns your maximum health/spirit/stamina/mana as an integer (class Fixnum). Takes no arguments.


== pause_script ==
===pause_script===
<pre style="overflow:hidden;">
pause_script
pause_script
pause_script "test"
pause_script "test"
</pre>
*'''Returns:''' true/false
*'''Returns:''' true/false
*'''Description:''' If given no arguments, pauses the script using the command. If given a string, pauses the script who's name matches that string; if the script is not currently active, returns 'false' ('true' if the script was paused successfully).
*'''Description:''' If given no arguments, pauses the script using the command. If given a string, pauses the script who's name matches that string; if the script is not currently active, returns 'false' ('true' if the script was paused successfully).


== unpause_script ==
===unpause_script===
<pre style="overflow:hidden;">
unpause_script "test"
unpause_script "test"
</pre>
*'''Returns:''' true/false
*'''Returns:''' true/false
*'''Description:''' Unpauses the script you give it. Note that because of the way the 'script is paused' state is handled, it's conceivable for a script that was paused to actually still be executing commands internally for a brief time -- a script isn't actually "stopped dead in its tracks" until it attempts to interact with the game in some way (by fetching game data, sending game data, or by attempting a command that requires the script to be identified). Since most commands identify a script (including this one), this command cannot unpause the script itself: when it attempts to unpause itself, it will be identified as being paused and will be halted where it is until it's unpaused by another script or the user (or killed). When it is, it will be allowed to continue, and will then try to unpause itself (pointlessly, since it was just unpaused...).
*'''Description:''' Unpauses the script you give it. Note that because of the way the 'script is paused' state is handled, it's conceivable for a script that was paused to actually still be executing commands internally for a brief time -- a script isn't actually "stopped dead in its tracks" until it attempts to interact with the game in some way (by fetching game data, sending game data, or by attempting a command that requires the script to be identified). Since most commands identify a script (including this one), this command cannot unpause the script itself: when it attempts to unpause itself, it will be identified as being paused and will be halted where it is until it's unpaused by another script or the user (or killed). When it is, it will be allowed to continue, and will then try to unpause itself (pointlessly, since it was just unpaused...).


== percenthealth/percentmana/percentspirit/percentstamina ==
===percenthealth/percentmana/percentspirit/percentstamina===
<pre style="overflow:hidden;">
fput "eat my acantha leaf" while (percenthealth < 90)
fput "eat my acantha leaf" while (percenthealth < 90)
</pre>
*'''Returns:''' integer
*'''Returns:''' integer
*'''Description:''' Returns an integer (0-100) representing the percentage of your current health/mana/whatever in relation to your max.
*'''Description:''' Returns an integer (0-100) representing the percentage of your current health/mana/whatever in relation to your max.


== running? ==
===running?===
<pre style="overflow:hidden;">
running? "test"
running? "test"
</pre>
*'''Returns:''' true/false
*'''Returns:''' true/false
*'''Description:''' Takes a string and returns true/false if the given script is active or not.
*'''Description:''' Takes a string and returns true/false if the given script is active or not.


== variable ==
===variable===
<pre style="overflow:hidden;">
variable[1]
variable[1]
</pre>
*'''Returns:''' an array, possibly empty
*'''Returns:''' an array, possibly empty
*'''Synonyms:''' script.vars
*'''Synonyms:''' script.vars
*'''Description:''' It's an array containing the command line variables the user entered when starting the script (begins at variable[1], unlike standard arrays; as is the behavior of Wizard, variable[0] is the entire line the user entered).
*'''Description:''' It's an array containing the command line variables the user entered when starting the script (begins at variable[1], unlike standard arrays; as is the behavior of Wizard, variable[0] is the entire line the user entered).


== checkspell ==
===checkspell===
<pre style="overflow:hidden;">
checkspell "elemental defense i"
checkspell "elemental defense i"
</pre>
*'''Returns:''' true/false
*'''Returns:''' true/false
*'''Synonyms:''' active?
*'''Synonyms:''' active?
*'''Description:''' Returns true if the spell you give it is active, false if it isn't (only available if you use the infomon script, since that's what keeps track of this).
*'''Description:''' Returns true if the spell you give it is active, false if it isn't (only available if you use the infomon script, since that's what keeps track of this).


== die_with_me ==
===die_with_me===
<pre style="overflow:hidden;">
die_with_me "test", "calcredux", "etc"
die_with_me "test", "calcredux", "etc"
</pre>
*'''Returns:''' true
*'''Returns:''' true
*'''Description:''' If the given scripts are active at the time the script using this command ends (exits itself, finishes, gets killed by the user, or dies in error) they'll all be killed automatically (produces no notification to avoid clutter, but the scripts are indeed stopped). The given scripts need not be running (or technically even exist) at the time this command is used -- it only updates the setting, and that setting isn't actually acted upon until the script is killed.
*'''Description:''' If the given scripts are active at the time the script using this command ends (exits itself, finishes, gets killed by the user, or dies in error) they'll all be killed automatically (produces no notification to avoid clutter, but the scripts are indeed stopped). The given scripts need not be running (or technically even exist) at the time this command is used -- it only updates the setting, and that setting isn't actually acted upon until the script is killed.


== before_dying ==
===before_dying===
<pre style="overflow:hidden;">
before_dying { echo "Oh God, why have you killed me dear user...?!" }
before_dying { echo "Oh God, why have you killed me dear user...?!" }
before_dying { Settings.save }
before_dying { Settings.save }
</pre>
*'''Returns:''' true
*'''Returns:''' true
*'''Description:''' Performs the given actions right before the script exits. Note nothing is done at the time this command is used (it simply sets what should be done just before the script is killed). The block given to this command is actually wrapped up into a proc object (an object of the 'Procedure' class), and scheduled to be run when the script is killed/exits (if multiple procs exist, they are executed sequentially in the order they were declared). Because of this, the same 'binding' principles that apply to other proc objects apply here (in a nutshell, if a variable didn't exist when you declared the 'before_dying' stuff, then you can't use it in the 'before_dying' code; if it did exist at the time though, you *can* use it, even if it doesn't really exist in the script when it dies). Also note that if the command(s) take more than 0.5 seconds to complete, they're forcibly aborted and the script is killed regardless (this is to prevent a possibly bad situation where a script makes a mistake in the 'before_dying' command and is refusing to stop executing due to errors). Note that if a script is set as executing in SAFE mode, all the restrictions that normally apply will also apply in the 'before_dying' code block (this cannot circumvent that, nor can anything else for that matter).
*'''Description:''' Performs the given actions right before the script exits. Note nothing is done at the time this command is used (it simply sets what should be done just before the script is killed). The block given to this command is actually wrapped up into a proc object (an object of the 'Procedure' class), and scheduled to be run when the script is killed/exits (if multiple procs exist, they are executed sequentially in the order they were declared). Because of this, the same 'binding' principles that apply to other proc objects apply here (in a nutshell, if a variable didn't exist when you declared the 'before_dying' stuff, then you can't use it in the 'before_dying' code; if it did exist at the time though, you *can* use it, even if it doesn't really exist in the script when it dies). Also note that if the command(s) take more than 0.5 seconds to complete, they're forcibly aborted and the script is killed regardless (this is to prevent a possibly bad situation where a script makes a mistake in the 'before_dying' command and is refusing to stop executing due to errors). Note that if a script is set as executing in SAFE mode, all the restrictions that normally apply will also apply in the 'before_dying' code block (this cannot circumvent that, nor can anything else for that matter).


== undo_before_dying ==
===undo_before_dying===
<pre style="overflow:hidden;">
undo_before_dying
undo_before_dying
</pre>
*'''Returns:''' true
*'''Returns:''' true
*'''Description:''' Clears any 'before_dying' commands that have been used for the script.
*'''Description:''' Clears any 'before_dying' commands that have been used for the script.

== Wounds.torso ==
Wounds.torso
Wounds.neck
Wounds.lhand
# etc...
*'''Returns:''' an integer
*'''Synonyms:''' Wounds.head; Wounds.neck; Wounds.abs; Wounds.lhand; Wounds.rhand; Wounds.larm; Wounds.rarm; Wounds.chest; Wounds.back; Wounds.rleg; Wounds.lleg; Wounds.nerves
*'''Description:''' Returns the current wound rank (numerically). If I had 'deep gashes and serious bleeding' on my chest, Wounds.chest would return the integer 3. If I had no wound there, it would return 0.

== Scars.torso ==
Scars.nerves
Scars.lleg
# etc...
*'''Returns:''' an integer
*'''Description:''' Identical to the Wounds.(bodypart) commands seen above, but for scars instead of wounds.

== GameObj ==
*'''Description:''' The GameObj class tracks various objects in the same room as you, and makes their game id, name, noun, status, and contents available to you.
GameObj.inv
*'''Returns:''' an array of objects of the GameObj class representing the things you are wearing.
GameObj.pcs
*'''Returns:''' an array of objects of the GameObj class representing the other players in the room, or nil if there are none.
GameObj.npcs
*'''Returns:''' an array of objects of the GameObj class representing the npcs in the room, or nil if there are none.
GameObj.loot
*'''Returns:''' an array of objects of the GameObj class representing the loot in the room, or nil if there is none. For the purposes of this function, loot is anything that Simu hasn't tagged with monster bold. Any exits or anything that shows up in the "You also see" line will be included.
GameObj.room_desc
*'''Returns:''' an array of objects of the GameObj class representing any links found in the room description, or nil if there are none.
GameObj.right_hand
GameObj.left_hand
*'''Returns:''' an object of the GameObj class representing whatever is in your hand. Currently, if there is nothing in your hand, it still returns a GameObj where the name is "Empty".
GameObj.fam_pcs
GameObj.fam_npcs
GameObj.fam_loot
GameObj.fam_room_desc
*'''Returns:''' an array of objects of the GameObj class. Similar to the ones above, except for your familiar's room, and these don't stay up-to-date without having your familiar look at the room.
Now that you've got an object or array of objects, here's what to do with them:
target = GameObj.npcs.find { |npc| npc.status.nil? }
if target
fput "attack ##{target.id}"
end
*'''Description:''' This example shows (in an over-simplified way) the most common use of the GameObj class. First, "GameObj.npcs" gives an array of all the npcs in the room. Then, ".find" searches each item in that array. For each item in the array, the code inside the brackets following "GameObj.npcs.find" is run, and "npc" represents the item it's currently looking at. The code inside the brackets acts like an if statement, and as soon as it is true, "target" is assigned the npc object.<br>
The "status" method applies to npcs and pcs (using it on others won't give an error, but it will always return nil). The status is basically whatever shows up after "that appears", "that is", or "who is". So, if you also see a kobold that appears stunned, its status will be "stunned". In the example, we're looking for an npc with a nil status, because that represents an npc that's standing and not stunned, dead, prone, etc. The game never shows "You also see a kobold that is standing."<br>
Now suppose there's twenty kobolds in the room, and only the fifteenth one is standing. How can you be sure you attack the standing one? This is where the kobold's id comes in handy. Simu assigns an id to almost everything in the game. Stormfront uses these ids when you click on links. For the most part, these ids can be used just like nouns. "attack ##{target.id}" will attack the npc you found earlier, even if other npcs are walking in and out of the room. The double pound sign is not a typo.
.id
.name
.noun
.status
.contents

==References==
*The initial content of this article was copied from the scripting documentation posted by Tillmen which formerly resided at http://lichproject.com/


[[Category:Scripts]]
[[Category:Scripts]]

Revision as of 01:29, 30 March 2013


The Lich scripting engine allows you to automate many of your routine tasks through scripts. Lich scripts are written in Ruby, so you have some powerful Ruby features available, such as GTK bindings to create GUIs.

If you are more comfortable with StormFront and Wizard scripts, Lich can run most of them unaltered, but since Lich is running them, you can have any number of them running simultaneously. Lich is highly compatible with StormFront/Wizard scripts, so you can use your existing scripts and scripting experience when writing Lich scripts.

Running a Script

By preceding your script name with the prefix character, which defaults to a semicolon ; character, you can run a script. For example, if you created a script named sell-loot then issuing the command ;sell-loot would run the sell-loot script.

Passing Variables to Scripts

You can also supply arguments to the script by adding the arguments after the script name. A script can act on these arguments or use them to modify the behavior.

;sell-loot gems

This will run the sell-loot script with variable[1] set to "gems".

;sell-loot gems skins

This will run the sell-loot script with variable[1] set to "gems" and variable[2] set to "skins". Sometimes you want to use spaces in your arguments, so you can use quotes:

;sell-loot "a fancy gem" skins

This will set variable[1] to "a fancy gem" and variable[2] to "skins".

Stopping a Script

A script ends when it reaches the last command or encounters the exit command. A script can be killed with the ;kill command.

Labels and the Goto Command

A label is a spot in the code where a command can branch to with certain commands. They are given unique names followed by a colon. For example:

loop:
move n
goto "loop"

This script contains one label named loop. As written, this script will continually move north until it is killed by the user e.g. via ;kill. Because of the goto loop, it will never end on its own.

A script label can be any string of characters, so long as it does not have a space. Each label must be unique in a script. You cannot have two labels with the same name. For the purposes of matching labels, case is ignored. Therefore "Bob" is the same as "bob" is the same as "BOB" etc.

There is a special catch-all label labelError. If a script command tries to branch to a label that is not found, the script will abort with an error unless there is a labelError: label. If the label exists, it will branch this catch-all label.

Label names can be constructed from variables in commands such as goto. For example:

goto "label" + variable[1]

label1:
echo "The first variable was 1"
exit

label2:
echo "The first variable was 2"
exit

label3:
echo "The first variable was 3"
exit

Commands

put

put "look"
  • Returns: the string that was sent
  • Description: Identical to Wizard.

fput

fput "stance defensive"
fput "stance defensive", "are now in a defensive stance", "can't do that while dead", "etc"
  • Returns: the string that was accepted as meaning the action succeeded (see below)
  • Synonyms: forceput
  • Description: It's named 'forceput' because originally it was intended to be used only infrequently, but as it's turned out there are very few times when 'put' is preferable. This command will continue to 'put' whatever string you give it, until it receives a line from the game that it doesn't recognize as one of the common "command rejected" responses (for example, "You can't do that while entangled in a web", "...wait x seconds" (RT), "Wait x seconds." (cast RT), "Sorry, you may only type ahead x lines", "You'll have to stand up first" (stands and reattempts), etc). If stunned, it will wait until you're no longer stunned to reattempt; if in RT (hard or soft), will wait 'x' seconds before reattempting. If you need to stand, it will do so and retry immediately. If it causes a type ahead error, it will pause for 1 second and then reattempt. This has a very high rate of success, but it is definitely not infallible -- it only checks the next line received from the game, and there's no guarantee the next line from the game has anything at all to do with what the 'fput' command just sent. Because of this it can often fail to realize the command wasn't really successful, particularly if the user is doing a lot of things at once. If given more than one string, the first string is taken as the command to send to the game, and all other strings are used as what to accept as meaning the action succeeded. BE CAREFUL with this behavior! It can very infrequently be extremely useful, but if not used cautiously, it can easily cause a script to mistakenly repeat an action many times in *very* rapid succession (which with CoL signs for instance can very easily kill you in less than a second flat).

pause

pause 1
pause '2s'
 pause '3m'
 pause '2h'
 pause '1d'
  • Returns: an integer
  • Description: If given no arguments, pauses for one second. If given an integer, pauses for that many seconds. If given a string (as in the examples above), extracts the number to pause for from the string and pauses for that many seconds/hours/days (yeah, well, I was bored, so why not make it do days too). Return value is the number of seconds it paused for.

echo

echo "Hi there!"
 echo "Line one", "Line two", "endlessly"
  • Returns: a string
  • Description: Displays '[script_name: the string it was given]' in the game window; if given multiple strings it echoes each string on its own line. If it's given no arguments, it simply prints a blank line without the '[script_name: ]' business.

respond

respond
 respond "I'm a string to display"
 respond "Line one", "Line two", "so on and so on"
  • Returns: integer
  • Description: Just like the 'echo' command, but does not display the script name. Since it's possible for Lich to be running two dozen scripts at the same time, it can get a little hard to know which script is saying what unless they use the 'echo' command and not the 'respond' command. Still, 'echo' can be a bit ugly for printing tables and whatnot, so use this instead if desired. The return value is how many characters the last string displayed contained.

goto

goto "MainLabel"
  • Returns: (has no return value, the current execution stack is discarded and the jump never returns)
  • Description: Identical to standard Wizard/SF scripts; the label to jump to has to be in quotes, and its case insensitive. The label declaration itself (the LABEL: line) MUST NOT be in quotes: only the name of the label when you use the goto command. If a label called "main" and a label called "Main" (with a capital) both exist, then using goto to jump to the "main" label would jump there -- however, if you tried to jump to the "Main" label, it would jump to the capital-letter one instead (basically if there are two labels with the same name but different capitalization, the goto command starts acting as though its case sensitive).

wait

wait
  • Returns: a string
  • Description: Identical to Wizard; waits until a line from the game is seen. Returns the line (in actuality this command simply clears the game stack and executes a 'get').

waitrt

waitrt
  • Returns: an integer (Fixnum class)
  • Description: Pauses for however many seconds you're currently in roundtime for. Return value is how many seconds paused. Waits until you're in roundtime if you aren't at the time this command is used, and therefore can hang endlessly.

waitrt?

waitrt?
  • Returns: an integer (Fixnum class)
  • Description: Identical to 'waitrt', but does not wait until you're in roundtime and as such will not hang (but will not wait for any roundtime if the game hasn't sent that you're in roundtime yet).

waitcastrt

waitcastrt
  • Returns: an integer (Fixnum class)
  • Description: Pauses for however many seconds you're currently in RT for. Return value is how many seconds paused. Waits until you're in RT if you aren't at the time this command is used, and therefore can hang endlessly.

waitcastrt?

waitcastrt?
  • Returns: an integer (Fixnum class)
  • Description: Identical to 'waitcastrt', but does not wait until you're in cast roundtime and as such will not hang (but will not wait for any cast roundtime if the game hasn't sent that you're in cast roundtime yet).

waitfor

waitfor " just arrived.", "More lines to waitfor if you desire", "endlessly"
  • Returns: a string
  • Description: Waits until a line from the game includes the string you gave it as an argument. The return value is the complete string from the game (in the example used here, if Shaelun entered the room, the command would return "Shaelun just arrived."). 'waitfor' is case insensitive (capital letters are considered matches even if the string it was given didn't have a capital letter there).

unique_waitfor

unique_waitfor "continue"
  • Returns: a string
  • Description: Same as 'waitfor' but acts on the 'unique' queue.

wait_while

wait_while { percenthealth != 100 }
 wait_while "You do not have full health: waiting until you do." { percenthealth != 100 }
  • Returns: true/false
  • Synonyms: all the variants of `Wounds.(bodypart)' are the same for `Scars.(bodypart)'
  • Description: The script will wait while the given code block has a logical value of 'true', and will only continue on to the next line when/if the code block has a value of 'false'. If given the optional string to announce to the user, it will only display that string if it's going to be sitting there waiting for something -- if the command will not be waiting at all, it doesn't display the string to the user. Note that there's no limit to how long/complicated the code block can be; it was designed for very short logical comparisons like the example above, but need not be used that way.

wait_until

wait_until { checkmana(50) }
  • Returns: true/false
  • Description: Identical in all ways to 'wait_while', but does the opposite (waits UNTIL the given code block is true, not WHILE it's true). Also takes the optional string if desired.

upstream_get

upstream_get
  • Returns: a string
  • Description: Same thing as "get" except it fetches the last line the user sent to the game. A script has to ask Lich to give it this information by first using the "toggle_upstream" command.

toggle_upstream

toggle_upstream
  • Returns: updated value of the "upstream" flag (true/false)
  • Description: See above.

upstream_waitfor

upstream_waitfor "climb stairs"
  • Returns: a string
  • Description: Identical to "waitfor" but only checks the upstream commands (the commands sent to the game by the user).

undo_before_dying

undo_before_dying
  • Returns: nothing useful
  • Description: Clears any "before_dying" code blocks that have been used. If none have been used, does nothing (see the 'before_dying' command).

abort!

abort!
  • Returns: never returns
  • Description: Immediately kills the script, bypassing any 'before_dying' blocks that have been registered. Probably won't ever be of use, but it's a way to make the calling script go away as fast as possible (note that it isn't any faster than the 'exit' command is, it just makes sure that nothing except stopping the script happens).

watchhealth

watchhealth(50) { echo "Uh, your health is below 50..." }
 watchhealth(50, proc_object)
  • Returns: nothing useful
  • Description: Returns immediately so that the calling script continues to run as normal, and while it does, monitors your health. If it falls below the number you give it, executes the block you passed to it. Only does this once -- if you want it to repeat as the script executes (be careful, chances are your health will still be below 50 after the block executes once) then pass watchhealth a proc object that includes a line registering itself over again (as in, a proc that includes a 'watchhealth(#, self)' thingie). If your health never falls below the number you give it, then nothing happens; once the script ends, it stops watching.

checkoutside

checkoutside
 outside?
  • Returns: true/false
  • Synonyms: outside?
  • Description: Really simple, just returns true if you're outside, false if you aren't. Probably only of use to rangers writing their own spellup scripts or something, but either way: it's available if you have a use for it.

Settings.load

Settings.load
 Settings["SettingName"]
 Settings.save
 Settings.clear
  • Returns: either a hash representing your settings, or 'nil' if no settings for the script exist
  • Description: Note that Settings.clear will erase all settings, but it will NOT save that on its own. Issue a Settings.save command after the Settings.clear if you want that script's settings reset permanently.

toggle_unique

toggle_unique
  • Returns: updated value of the 'unique' setting (true or false)
  • Description: When a script is set as being 'unique', it does not receive normal game data; instead it only receives what the user sends to it by typing ;send to (script) (message). This is of use if a script wants to only act on a user's input or has no use for game data (it provides a method for scripts to make sure game data doesn't accidentally get recognized as a user's input, and also serves to prevent scripts from slowly eating away at system resources because the script never checks or clears its data buffer -- see the 'clear' command for more on that).

no_kill_all

no_kill_all
  • Returns: updated value of the 'no_kill_all' setting (true or false)
  • Description: Toggles on/off the 'no kill all' setting: when this setting is on (defaults to off), a script will not be effected by the user typing ;kill all. A script with this set to on must be killed specifically (by typing ;kill [script], or just ;kill). There is no way to prevent a script from being killed when targeted by the user.

silence_me

silence_me
  • Returns: new value of the 'silenced' setting (true or false)
  • Description: Toggles on/off the 'silenced' setting. A script with this on will not have commands it sends to the game echoed to your game window. A script run in SAFE mode cannot change this setting (attempting to do so will generate a warning and otherwise have no effect).

toggle_echo

toggle_echo
  • Returns: new value of the 'suppress echo' setting (true or false)
  • Description: Toggles on/off the 'suppress echo' setting. A script with this on will not execute any 'echo' commands, but will silently ignore them instead; it's designed more for people who don't want clutter in their game window but still want to make use of an existing script. Commands sent to the game are still echoed to the game window.

checkpoison

checkpoison
  • Returns: true/false
  • Description: See checkdisease.

checkdisease

checkdisease
  • Returns: true/false
  • Description: See checkpoison.

get

get
  • Returns: a string
  • Description: Fetches the next un-checked line of game data (while a script is running, it is given every game line, and these lines are available for a script to check/use at its leisure).

unique_get

unique_get
  • Returns: a string
  • Description: Fetches a line from the unique stack, as opposed to the game data stack (see 'toggle_unique' for more about what the 'unique' stack refers to).

send_to_script

send_to_script 'scriptname', 'message to send'
  • Returns: true or false
  • Description: The target script will be sent a string exactly as though it came from the game. Returns true if successful, false if the script wasn't found to be active.

unique_send_to_script

unique_send_to_script 'scriptname', 'message to send'
  • Returns: true or false
  • Description: Same as 'send_to_script', but the script will receive the string sent in its 'unique' stack instead of its 'game data' stack (see 'toggle_unique' for more info).

move

move 'northwest'
  • Returns: true or false
  • Description: Same as the Wizard 'move' command, but it will usually compensate for things like type ahead errors, RT, currently stunned, etc.; will also stand and re-attempt the movement if it's detected to be necessary. Returns 'true' if the move was executed properly, 'false' if it wasn't able to be performed (which is very rare due to the move command's error compensation measures).

multimove

multimove 'nw', 'ne', 'go hole', 'climb stairs'
  • Returns: true or false
  • Description: Takes multiple directions to move in and executes the 'move' command for each one. Returns the value of the last 'move' command executed (true or false).

fetchloot

fetchloot
  • Returns: a string
  • Description: Performs a 'look' and takes/puts away all items on the ground that aren't listed in your 'excludeloot:' setting. Return value is the last line from the game.

Lich.fetchloot

Lich.fetchloot
  • Returns: a string
  • Description: Identical to 'fetchloot' in all ways except only the items listed in your 'treasure:' setting are fetched.

checkloot

checkloot
  • Returns: an array of strings (or an empty array if no items)
  • Description: Returns an array consisting of the items currently in the room.

take

take "box", "coffer", "ruby", "etc"
  • Returns: a string (the last line the 'fput' command saw)
  • Description: Picks up every item listed and puts each one in turn into your 'lootsack:' setting by issuing the commands with fput.

checkpaths

checkpaths
 checkpaths 'nw'
  • Returns: an array of strings, or true/false
  • Description: Returns an array consisting of the current 'Obvious exits:' directions if given no argument, or true/false based on whether all arguments given are currently available as exits or not.

walk

walk
  • Returns: true or false
  • Description: Moves in a random cardinal direction (what's seen in the 'Obvious exits:' line), storing the direction moved, and returning 'true' if there is a critter in the room or 'false' if there aren't any NPCs in the room. The stored direction will not be among the random directions chosen the next time the 'walk' command is used (unless it hits a dead-end, then it will backtrack the way it came).

run

run if not health(50)
  • Returns: true or false
  • Description: Will execute a 'walk' command repeatedly until it enters a room with no critters, at which point it returns and the script will pick up execution on the next line (does not continue to run away).

checkfried

checkfried
  • Returns: true or false
  • Description: Returns true if you're fried, false if not.

checkmind

checkmind
 checkmind(2)
  • Returns: true or false, or a string
  • Description: By itself returns a string representing the level of exp in your head ('clear as a bell', 'fried', 'muddled', etc). If given an integer, returns true or false if you have the corresponding level of exp in your head.

percentmind

percentmind
 percentmind(80)
  • Returns: integer, or true or false
  • Description: By itself returns an integer ranging from 0-100 representing the percentage of exp in your head. If given an integer, returns true or false if you have at least that percentage of experience. Both saturated and fried show up as 100 percent - a user interested in distinguishing between the two can add a checksaturated or saturated? qualifier to their percentmind check.

checkarea

checkarea
 checkarea "illistim"
  • Returns: a string, or true or false
  • Description: By itself returns the geographical area of your current room, or if given a string to check for, returns true or false based on whether your current area matches the string or not.

checkroom

checkroom
 checkroom "table"
  • Returns: true or false, or a string
  • Description: Identical to checkarea, but uses the room title instead of the geographical area.

checkfamarea/checkfamroom

checkfamarea
 checkfamarea "illistim"
  • Returns: a string, or true/false
  • Description: Identical to checkarea/checkroom, but check your familiar's current location instead of yours (only in Wizard and only if you have a familiar).

checkright/checkleft

checkright
 checkleft "broadsword"
  • Returns: true or false, or a string
  • Synonyms: righthand?/lefthand?
  • Description: Give them a string and will return true/false if it matches what you're holding, or the last word in the item name if used by itself. If your hands are currently empty, it will return 'nil' (identical to 'false' in a logical comparison) regardless of whether it was given an argument or not. This behavior can be useful to make absolutely certain a 'take' command succeeded, for instance.

check(thing)

checkstanding
 checkspell "spirit defense"
 checkdead
  • Returns: mostly true/false
  • Synonyms: checkstanding; checknotstanding; checksitting; checkprone; checkkneeling/kneeling?; checkprep/prepped?; checkmind; checkgrouped/checkjoined/joined?; checkwebbed/webbed?; checkstunned/stunned?; checkdead/dead?; checkhidden/checkhiding/hidden/hiding?; checkname/myname?; checkspell/checkactive/active?
  • Description: Most are true if you are (checkstunned for example), false if you aren't; they all follow the same basic behavior as the above-documented 'check' commands.

checkname

checkname
 checkname "Shaelun"
  • Returns: string or true/false
  • Description: True/false if given a string and the names match, or just returns the character name if given no arguments.

checknpcs

if checknpcs
     fput "attack"
 end
 if checknpcs "big monster of doom", "small monster of doom"
     put "Oh noes!"
 end
 for npc in checknpcs
     put "greet #{npc}"
 end
  • Returns: an array of strings, a string, or nil
  • Description: If checknpcs is used without giving it npcs to check for, it returns an array of strings corresponding to the noun of each npc in the room, or nil if there are no npcs (does not return an empty array, so you can use "if checknpcs"). If chekcnpcs is given npcs to look for, it returns a string of the first matching npc it finds, or nil if none matched (any string evaluates to true, only nil and false evaluate to false in an if statement).

checkpcs

checkpcs
 checkpcs "shaelun"
  • Returns: array of strings, or true/false
  • Description: Identical to 'checknpcs', but with the players currently present.

checkfampcs

checkfampcs "shaelun"
 checkfampcs
  • Returns: array of strings, or true/false
  • Synonyms: checkfamnpcs
  • Description: Identical to the above two, but tracks for your familiar's room instead. Not available in SF as of v3.06.

checkstamina

checkstamina 50
 checkstamina
  • Returns: true/false or an integer
  • Description: Only in StormFront (there is no auto-updated stamina tag in Wizard). Given no arguments, returns your current stamina. Given a number, returns true/false based on whether you have at least or more than that number.

checkmana/checkhealth/checkspirit

checkmana 50
  • Returns: identical as above
  • Synonyms: health, health?, mana, mana?, spirit, spirit?
  • Description: Identical to checkstamina.

clear

clear
  • Returns: an array of strings (possible for the return array to be empty, but unlikely)
  • Description: Empties ALL unchecked input to the script from ALL queues (normal game stack, unique script stack and upstream stack); the return value is whatever was in the game data stack before it was cleared (which could be nothing, in which case the return is an empty array).

i_stand_alone

i_stand_alone
  • Returns: updated value of the setting (true/false)
  • Description: Toggles on/off. Removes a script from ALL data feeds; a script using this will receive no game lines and no unique data whatsoever (unless they toggle it back off). If Lich can more or less ignore that a script exists and not bother with keeping its data stacks up-to-the-second with game data and anything else it's requested, then a script has virtually no overhead whatsoever (meaning any resources it requires come only from what it does independently). Useful for some scripts who have no need to eat up resources being fed game data (such as dict.lic).

matchtimeout

matchtimeout 5, "string to watch for", "another", "endlessly"
  • Returns: a string, or false
  • Description: Same as 'waitfor', but if a match isn't seen in the given amount of time, returns a value of 'false' and the script will move on.

matchwait

  • Returns: a string
  • Description: If used without any arguments, 100% identical to Wizard 'matchwait' commands. You can optionally give it arguments, in which case it acts identically to 'waitfor' in all ways except one: matches are case sensitive (for instance, matchwait "shaelun" will not match if the word "Shaelun" is seen from the game).

match

match 'label', 'line to watch for'
 match "gameline", "gameline", "some other gameline", "so on and so forth"
  • Returns: a string
  • Description: If given exactly two arguments, identical to the Wizard 'match' command. If given *any* other number of arguments, it's a case sensitive version of 'waitfor' but instead of returning the entire matching game line, it returns only the portion of the string you asked it to watch for.

matchfind

matchfind "A ? attacks you!", "A ? swings a ? at you!"
 person, weapon = matchfind "? swings a ? at you!"
  • Returns: a string or an array
  • Description: Same as 'waitfor', but returns only the portion of the line where the question mark(s) are. If given multiple question marks, returns an array containing the portions of the string (in order). Note that if you assign multiple variables to equal a single array, the array's elements are used in order and assigned to each variable (if there are fewer elements in the array than there are variables being assigned, variables receive a value of 'nil', and if there are more elements in the array than there are variables being assigned, the last variable is assigned an array with the remaining values). This is why the above usage example works (person, weapon =).

matchfindword

weapon = matchfindword "Shaelun swings a ? at you!"
  • Returns: a string (single word)
  • Description: Identical to 'matchfind', but only looks for a single word where the question marks are. Note that a line won't match if more than one word is where the question mark is (in the above example, if the weapon were a "broadsword" it would match, but if it were a "sonic hammer of kai" there would be no match).

matchfindexact

matchfindexact "? just arrived."
  • Returns: a string
  • Description: Version of matchfind meant for use in special cases; matchfind is very forgiving and will return and match anything (case insensitively) -- matchfindexact is very strict. It is case sensitive and cares about things like spaces, word boundaries (partial pieces of a word will not match, only whole words), the case of the string it's looking for, etc.. Use it if you need to use matchfind and want to make sure only a very specific line matches.

send_scripts

send_scripts "To the running scripts, this line looks identical to one that came from the game"
  • Returns: true/false
  • Description: Same as 'send_to_script', but sends a line to all scripts instead of just one.

regetall

regetall "Shaelun"
  • Returns: an array of strings, or nil
  • Description: Takes a string and returns an array of all game lines (since login) that match as having contained the given string (absolutely every single line since you logged in, Lich remembers them all). If a script is set as receiving the status data that doesn't show in the game window, those lines are also matched for; if the script is only being fed normal game data, that's the only history this command checks. If no matching lines were found, returns 'nil' (which is false in a logical comparison). As well as returning the matches, it also adds them to the script's game data stack so that subsequent 'get' commands will fetch them in order. The string to match for is actually optional, and if omitted, all lines are considered 'matching'.

reget

reget 3
 reget 5, "Shaelun"
  • Returns: an array of strings, or nil
  • Description: Similar to 'regetall' in behavior, but it only checks the current RAM cache (every 2 minutes, Lich's 'memory' of game data is emptied out of RAM and stored in a temporary file on the hard disk so that the program doesn't take up more resources than is necessary -- these files are deleted when the program closes); it also takes an optional integer, which represents how many game lines back to check ('reget 5' would scan the last 5 lines from the game that are still in RAM). If the integer is omitted, will scan the entire existing RAM buffer (again, cleared every 2 minutes).

multifput

multifput "stance offensive", "incant 910", "stance defensive"
  • Returns: a string (return value of the last 'fput' executed)
  • Description: Takes multiple strings and executes an 'fput' command for every one sequentially.

kill_script

kill_script "test"
  • Returns: true/false
  • Synonyms: kill_scripts, stop_script, stop_scripts
  • Description: Simulates the user having entered ;kill test in the game entry box and hitting enter; takes multiple scripts to kill. If the script is not running, returns false; if the script was found to be active and was killed, returns true.

start_script

start_script "test"
 start_script "heal", [ "shaelun", "adhara" ]
  • Returns: true/false
  • Description: Simulates the user having entered ;test in the game entry box. Returns 'true' if the script was successfully started, 'false' if for any reason it couldn't be found/started. The optional second argument (which must be an array, as seen in the above example) can be used to simulate arguments to the script (the above example would simulate the user typing: ;heal shaelun adhara).

start_scripts

start_scripts "test"
 start_scripts "test", "calcredux", "etc"
  • Returns: true/false
  • Description: Executes a "start_script" command for every argument given. Note that you cannot give a script arguments when using this command.

start_wizard_script

start_wizard_script "test", [ "command line variable(s)", "etc" ]
  • Returns: true if successful, false if the script can't be found or run
  • Description: Same as 'start_script', but starts Wizard/SF script files.

maxhealth/maxstamina/maxmana/maxspirit

fput "eat my acantha leaf" while (checkhealth < maxhealth)
  • Returns: integer
  • Description: Returns your maximum health/spirit/stamina/mana as an integer (class Fixnum). Takes no arguments.

pause_script

pause_script
 pause_script "test"
  • Returns: true/false
  • Description: If given no arguments, pauses the script using the command. If given a string, pauses the script who's name matches that string; if the script is not currently active, returns 'false' ('true' if the script was paused successfully).

unpause_script

unpause_script "test"
  • Returns: true/false
  • Description: Unpauses the script you give it. Note that because of the way the 'script is paused' state is handled, it's conceivable for a script that was paused to actually still be executing commands internally for a brief time -- a script isn't actually "stopped dead in its tracks" until it attempts to interact with the game in some way (by fetching game data, sending game data, or by attempting a command that requires the script to be identified). Since most commands identify a script (including this one), this command cannot unpause the script itself: when it attempts to unpause itself, it will be identified as being paused and will be halted where it is until it's unpaused by another script or the user (or killed). When it is, it will be allowed to continue, and will then try to unpause itself (pointlessly, since it was just unpaused...).

percenthealth/percentmana/percentspirit/percentstamina

fput "eat my acantha leaf" while (percenthealth < 90)
  • Returns: integer
  • Description: Returns an integer (0-100) representing the percentage of your current health/mana/whatever in relation to your max.

running?

running? "test"
  • Returns: true/false
  • Description: Takes a string and returns true/false if the given script is active or not.

variable

variable[1]
  • Returns: an array, possibly empty
  • Synonyms: script.vars
  • Description: It's an array containing the command line variables the user entered when starting the script (begins at variable[1], unlike standard arrays; as is the behavior of Wizard, variable[0] is the entire line the user entered).

checkspell

checkspell "elemental defense i"
  • Returns: true/false
  • Synonyms: active?
  • Description: Returns true if the spell you give it is active, false if it isn't (only available if you use the infomon script, since that's what keeps track of this).

die_with_me

die_with_me "test", "calcredux", "etc"
  • Returns: true
  • Description: If the given scripts are active at the time the script using this command ends (exits itself, finishes, gets killed by the user, or dies in error) they'll all be killed automatically (produces no notification to avoid clutter, but the scripts are indeed stopped). The given scripts need not be running (or technically even exist) at the time this command is used -- it only updates the setting, and that setting isn't actually acted upon until the script is killed.

before_dying

before_dying { echo "Oh God, why have you killed me dear user...?!" }
 before_dying { Settings.save }
  • Returns: true
  • Description: Performs the given actions right before the script exits. Note nothing is done at the time this command is used (it simply sets what should be done just before the script is killed). The block given to this command is actually wrapped up into a proc object (an object of the 'Procedure' class), and scheduled to be run when the script is killed/exits (if multiple procs exist, they are executed sequentially in the order they were declared). Because of this, the same 'binding' principles that apply to other proc objects apply here (in a nutshell, if a variable didn't exist when you declared the 'before_dying' stuff, then you can't use it in the 'before_dying' code; if it did exist at the time though, you *can* use it, even if it doesn't really exist in the script when it dies). Also note that if the command(s) take more than 0.5 seconds to complete, they're forcibly aborted and the script is killed regardless (this is to prevent a possibly bad situation where a script makes a mistake in the 'before_dying' command and is refusing to stop executing due to errors). Note that if a script is set as executing in SAFE mode, all the restrictions that normally apply will also apply in the 'before_dying' code block (this cannot circumvent that, nor can anything else for that matter).

undo_before_dying

undo_before_dying
  • Returns: true
  • Description: Clears any 'before_dying' commands that have been used for the script.