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:

Useful Variables (Not available to plugins)

VariableDescription
window.sipletsArray of all window managers
winCurrent active window manager
window.currWinCurrent active window manager
win.pbPhonebook or connection info
win.pb.accountTrue if accounts are used
win.pb.nameMud name
win.pb.hostMud host (Electron only)
win.pb.portMud port
win.pb.accountNameAccount name (Phonebook only
win.pb.userCharacter name (Phonebook only)
win.pb.passwordPassword (Phonebook only
win.MSPsupportWhether MSP is active
win.MSDPsupportWhether MSDP is active
win.GMCPsupportWhether GMCP is active
win.MXPsupportWhether MXP is active
win.MCCPsupportWhether MCCP is active
win.wsopenedWhether connection is active
win.windowNameWindow/Connection name
win.topContiner.firstChildDIV of top/first window
win.windowDIV of current/active frame

Useful Functions

FunctionDescription
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.closeWindow(str)Close 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.removeTempMenu(str)Remove temp menu entries under str
win.dispatchEvent(str)Post an event string or json obj (w/'type')
win.onGMCP(str, callback)Register GMCP Listener for str prefix
win.onMSDP(callback)Register MSDP Listener
win.onConnect(callback)Register Connection Listener
win.onDisconnect(callback)Register Disconnect Listener
win.onReceive(callback)Register bytes received Listener
win.onDisplay(callback)Register html displayed Listener
win.onText(callback)Register text displayed Listener
win.onSend(callback)Register bytes array or string sent Listener
win.mapper.*The visual Mapper interface.

Useful Variables (Available only to plugins)

VariableDescription
window.urlCurrent connection url
window.localStorageMedia storage
window.namePlugin JSON field
window.versionPlugin JSON field
window.requiresPlugin JSON field
window.codePlugin JSON field
window.mxpPlugin JSON field
window.triggersPlugin JSON field
window.aliasesPlugin JSON field
window.timersPlugin JSON field
window.menusPlugin 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));
});