Scripts
An Script is a named bit of free-form javascript code that can be triggered
by an Action taken by a Trigger,
Timer, or Alias.
Like other editors, you can customize your global Scripts from the
Global Options/Scripts menu, or customize the Scripts that apply only
to the active mud window's phonebook entry through the Window/Scripts menu.
The top list field in the Scripts editor allows you to either begin adding a new
script, or editing or deleting an existing one from the list. When adding or
editing an entry, Red fields will denote those with invalid or missing data.
Changes to an Script will not be submitted so long as a Red field exists. The fields are
as follows:
- Name: The unique name of your Script. If a phonebook script name collides with
a global script name, then the phonebook one will be preferred.
- Script: The Javascript to execute. Entities/Variables may be included in strings
in scripts in the form '&varname;'.
Useful Variables (Not available to plugins)
| Variable | Description |
| window.siplets | Array of all window managers |
| win | Current active window manager |
| window.currWin | Current active window manager |
| win.pb | Phonebook or connection info |
| win.pb.account | True if accounts are used |
| win.pb.name | Mud name |
| win.pb.host | Mud host (Electron only) |
| win.pb.port | Mud port |
| win.pb.accountName | Account name (Phonebook only |
| win.pb.user | Character name (Phonebook only) |
| win.pb.password | Password (Phonebook only |
| win.MSPsupport | Whether MSP is active |
| win.MSDPsupport | Whether MSDP is active |
| win.GMCPsupport | Whether GMCP is active |
| win.MXPsupport | Whether MXP is active |
| win.MCCPsupport | Whether MCCP is active |
| win.wsopened | Whether connection is active |
| win.windowName | Window/Connection name |
| win.topContiner.firstChild | DIV of top/first window |
| win.window | DIV of current/active frame |
Useful Functions
| Function | Description |
| win.process(str) | Process MXP/Entities without display |
| win.submitInput(str) | Submit command to the mud |
| win.displayText(str) | Display Text in active window |
| win.playSound(str) | Play wav file named or url str |
| win.setEntity(str,str) | Set entity key to value |
| win.getEntity(str) | Get entity value |
| win.runScript(str) | Run script by name |
| win.enableTrigger(str) | Enable Trigger |
| win.disableTrigger(str) | Disable Trigger |
| win.isConnected() | Whether connection is active |
| win.displayAt(str,str) | Display string in MXP frame str(2) |
| win.clearWindow(str) | Clear window or MXP frame str |
| win.sendPlugin(str,str) | Send to plugin str, json doc str(2) |
| win.sendGMCP(str,str) | Send GMCP command str + json doc str(2) |
| win.sendMSDP(str,str) | Send msdp json doc str |
| win.submitHidden(str) | Submit hidden text to the mud |
| win.addTempTimer(obj) | Submit temp timer object (see #timer) |
| win.removeTempTimer(str) | Remove temp timer by name |
| win.addTempTrigger(obj) | Submit temp trigger object (see #trigger) |
| win.removeTempTrigger(str) | Remove temp trigger by name |
| win.addTempAlias(obj) | Submit temp alias object (see #alias) |
| win.removeTempAlias(str) | Remove temp alias by name |
| win.addTempMenu(str,obj) | Submit menu entries under str (see #menus) |
| win.removeTempAlias(str) | Remove temp menu entries under str |
| win.dispatchEvent(str) | Post an event string or json obj (w/'type') |
| win.mapper.* | The visual Mapper interface. |
Useful Variables (Available only to plugins)
| Variable | Description |
| window.url | Current connection url |
| window.localStorage | Media storage |
| window.name | Plugin JSON field |
| window.version | Plugin JSON field |
| window.requires | Plugin JSON field |
| window.code | Plugin JSON field |
| window.mxp | Plugin JSON field |
| window.triggers | Plugin JSON field |
| window.aliases | Plugin JSON field |
| window.timers | Plugin JSON field |
| window.menus | Plugin JSON field |
Special events
Scripts can also listen for special events from GMCP or MSDP.
win.addEventListener('gmcp', function(e) {
console.log('Got GMCP command ' + e.command + ' with data ' + JSON.stringify(e.data));
});
win.sendGMCP("core_hello", {"client":"Siplet","version":''+win.siplet.VERSION_MAJOR});
win.addEventListener('msdp', function(e) {
console.log('Got MSDP data ' + JSON.stringify(e.data));
});