A rudimentary OOB input parser from the webclient, for testing.

This commit is contained in:
Griatch 2016-04-06 21:00:16 +02:00
parent 4ccd78a97e
commit 4acea5a20d
3 changed files with 17 additions and 7 deletions

View file

@ -14,8 +14,8 @@ All messages is a valid JSON array on single form:
["cmdname", args, kwargs],
where kwargs is a JSON object that will be used as argument to call
the cmdname function.
where args is an JSON array and kwargs is a JSON object that will be
used as argument to call the cmdname function.
This library makes the "Evennia" object available. It has the
following official functions:

View file

@ -57,10 +57,20 @@ var input_history = function() {
// Grab text from inputline and send to Evennia
function doSendText() {
inputfield = $("#inputfield");
outtext = inputfield.val();
input_history.add(outtext);
inputfield.val("");
Evennia.msg("text", [outtext], {});
var outtext = inputfield.val();
if (outtext.length > 7 && outtext.substr(0, 7) == "##send ") {
// send a specific oob instruction
outtext = outtext.slice(7);
var arr = outtext.split(' ');
var cmdname = arr.shift();
var kwargs = arr.join(' ');
log(cmdname, kwargs);
Evennia.msg(cmdname, [], JSON.parse(kwargs));
} else {
input_history.add(outtext);
inputfield.val("");
Evennia.msg("text", [outtext], {});
}
}
// catch all keyboard input, handle special chars