Xpertmud:Scripting
From BattletechMUX
Xpertmud > Scripting
Contents |
Topics
Examples
Executing Perl Code
Xpertmud uses perl as primary scripting language. The following instructions assume that you know at least a little bit of perl, but the examples should be fairly easy to adjust even if you don't.
There are three ways you can use to execute perl code:
- Immediate input: just enter a perl command prefixed with '#' and hit enter.
- From your bookmark: The bookmark editor has a page where you can edit the script being executed at startup. The commands you put in there are executed as if entered by hand on the input line, so you have to prefix perl commands with '#' here, too.
- From an external perl file: This is the most comfy option when working with larger scripts. Just write perl code, save it in a .pl file, and use '#parse "filename.pl"' from your bookmark.
The available commands remain the same, no matter where they come from. Just the leading '#' is different. You can see a short description of each built-in command with the online-help:
- #help : show all available topics
- #help "<topic>" : displays help on <topic>, e.g. #help "addAlias"
Aliases
Aliases work on text you input. You can use them to create shortcuts or macros, or to execute perl functions with a simple command. There are four commands working with Aliases:
- listAliases : shows a list of all aliases, and wether they're active or inactive
- addAlias : create a new alias
- delAlias : delete one or more aliases
- setAliasState : switch aliases on or off
Triggers
Triggers are used to match text coming from the server, and can modify it on-the-fly or call perl functions.
- listTriggers
- addTrigger
- delTrigger
- setTriggerState
Example:
addTrigger("SPRINT",qr/^You shimmy side to side as you get more speed from your movement mode/,sub { XM::send("speed flank\n"); return shift;});
Timers
Execute a task or send a string every x seconds
- listTimers
- addTimer
- delTimer
- setTimerState
- getTime
- setTimerInc
Delayed Execution
Like timers, but only executed once
- listDelayed
- addDelayed
- delDelayed
- setDelayed
Hotkeys
- listKeyBindings
- addKeyBinding
- delKeyBinding
- setKeyBindingState
- showKeyNames
Examples
- A wake-up trigger playing audio files
- Little helper to make scode editing more comfortable
- Perl scripting tutorial thread
| | See Also: Plugins |
