jiMUD allows you to use javascript for macros, trigger, aliases, buttons, or context items. This allows for powerful and more advanced features over the basic #functions and just sending text.
To use scripting you just have to select script as the type from the type dropdown in the item editor.
$selected
- selected text$selectedword
- word under mouse when right clicked$selectedline
- line under mouse when right clicked$selectedurl
- url under mouse when right clicked$selword
same as $selectedword$selline
sane as $selline$selurl
same as $selected url
client.beep()
play system beep soundclient.readClipboard()
read text from clipboard, can also access from window.readClipboard()client.writeClipboard(text, html)
write text to clipboard, can also access from window.writeClipboard(text), html argument is optional, allows formated html markup of text for applications that support pasting htmlclient.readClipboardHTML()
read HTML from clipboard, can also access from window.readClipboardHTML()client.send(text, echo?)
send text directly to the mud, telnet code IAC is escaped, note you should always try and append a new line as most muds require it to process any text.text
the text to sendecho
echo text to display
client.sendRaw(text)
sends raw text directly to the mud as isclient.sendCommand(text)
sends a command as if sent from the command lineclient.sendBackground(text)
sends a command as if sent from the command line with out modifying the current command lineclient.print(text, newline)
print text to screen, newline argument is optional and controls weather to start a newline if last line was a fragment/promptclient.echo(text, fore, back, newline, forceline)
echo text to the screentest
the text to echofore
ansi foreground code default is local echoback
background colornewline
see this.printforceline
always force a new line regardless of current last line state
client.parse(text)
send raw text to the screen to be parsed and displayed, can be used to send raw ansi or MXP codedclient.sendGMCP(text)
send a GMCP formatted string to the mud, see GMCP spec notes for formatting, its mostly in {module, data} where data is a JSON formatted stringclient.notify(title, message, options)
display a windows notification for systems that support it, options are optionaltitle
the title of the notificationmessage
the message to displayoptions
additional options to customize the display Notification Optionsdir
- auto, rtl, ltricon
- full icon path, supports {variables}silent
- play sound or not, default false
client.raise(event, args, delay)
fire an event with optional delay and argumentsevent
the event name to fireargs
an optional array of arguments to pass to the event, if you do not want to pass arguments but want a delay just pass 0 or []delay
the number of milliseconds to wait before firing event- Example"
client.raise('get all', [], 2000);
client.show()
show clientclient.hide()
hide clientclient.toggle()
toggle hide and showclient.sendChat(text)
send text to chat window
WARNING: you can effect the client if you access the wrong function, so any function used other then this list may caused unknown results and could cause the client to stop working
Notice how all the functions have a client. in front of them, this is the client object that has all functions related to the client. For backward compatible with the ShadowMUD web client we also support OoMUD and this for non ES6 arrow function formats.
- Name: alarm
- Style: script
- Value:
/*
Syntax to use: <alarm [message] [seconds]>
*/
//store message in local variable so it can be passed to timer
var message = arguments[1];
//convert to number and multiply by 1000 to convert to milliseconds
var ms = 1000 * parseInt(arguments[2], 10);
setTimeout( function() {
//echo message to screen
client.sendCommand("#echo " + message);
}, ms);
setTimeout(()=> {
//send a command to the mud
client.sendCommand("say Hello world.");
}, 2000);
//wait additional time to say it again
setTimeout(()=> {
//send a command to the mud
client.sendCommand("say Hello world again");
}, 4000);
//notice the timing is 4000 this is 2000 from the original + 2000 for the new for a total of 4 seconds
//Unlike zMUD where timing is build up, with javascript you will have to handle your own consecutive timing
/*
Start mono gray-scale rainbow example
syntax: monoline [line] [text]
to use this alias in OoMUD, create a new alias named monoline, set the style to Script
and ensure append arguments is checked
*/
//the line to display text on
var line = arguments[1];
//new string
var str = '';
//colors to use
var colors = [];
//random start
var offset = Math.ceil(Math.random()*1000);
//build color list
for(var i=0; i < 20; i++)
{
if(3+i < 10)
colors[i] = '%^mono0'+(3+i)+'%^';
else
colors[i] = '%^mono'+(3+i)+'%^';
if(23-i < 10)
colors[i+20] = '%^mono0'+(23-i)+'%^';
else
colors[i+20] = '%^mono'+(23-i)+'%^';
}
//start at arguments 2 since 0 is full line, and 1 is the line,
//so any thing after 2 is the text we want
var args = Array.prototype.slice.call(arguments);
var oldStr = args.slice(2).join(' ');
for(var c = 0; c < oldStr.length;c++)
{
var i = (c + offset) % colors.length;
str += colors[i]+oldStr.charAt(c);
}
this.sendCommand(line + ' ' + str);
//End mono grayscale example