diff --git a/ExtendedExpressions/extend.js b/ExtendedExpressions/extend.js
index 5ced42e423..812ad86fdb 100644
--- a/ExtendedExpressions/extend.js
+++ b/ExtendedExpressions/extend.js
@@ -237,7 +237,15 @@ var ExExp = ExExp || {
return operands.pop();
},
- sendCommand: function(chunks, asts, evalResults, inline, from){
+
+ write: function(s, who, style, from){
+ if (who){
+ who = "/w " + who.split(" ", 1)[0] + " ";
+ }
+ sendChat(from, who + s.replace(//g, ">").replace(/\n/g, "
"));
+ },
+
+ sendCommand: function(chunks, asts, evalResults, inline, from, labels){
// constants
var BINARY_FUNCTIONS = {
'||': function(x, y){ return x || y; },
@@ -273,7 +281,7 @@ var ExExp = ExExp || {
// local variables
- var labels = {}, references = {}, unevalRefs = [], evalReqs = [];
+ var references = {}, unevalRefs = [], evalReqs = [];
// helper functions
function lazyEval(t, labels, references, unevalRefs, evalReqs, force){
@@ -488,9 +496,14 @@ var ExExp = ExExp || {
if (t.type == "string"){ return t.value; }
var retval = flattenAST(t);
if (inline){ retval = "[[" + retval + "]]"; }
+ else if (t.type == "number"){ retval = "1d0 + " + retval; }
return retval;
}
+ function reportError(err){
+ ExExp.write("Error: " + err, from);
+ }
+
// substitute in results of base evaluation
for (var i = 0; i < evalResults.length; i++){
var t = evalResults[i][0];
@@ -508,7 +521,7 @@ var ExExp = ExExp || {
if (asts[i].baseValid){ continue; } // can be handled by base expression evaluator
if ((asts[i].type == "string") || (asts[i].type == "number")){ continue; } // tree is fully evaluated
var err = lazyEval(asts[i], labels, references, unevalRefs, evalReqs, false);
- if (typeof(err) == typeof("")){ return err; }
+ if (typeof(err) == typeof("")){ return reportError(err); }
}
// do variable substitution; repeat until we don't make any more progress
@@ -518,12 +531,12 @@ var ExExp = ExExp || {
// substitute in values for variables for which we already have names
for (var label in references){
if (!labels[label]){
- return "Variable '" + label + "' not defined";
+ return reportError("Variable '" + label + "' not defined");
}
if ((labels[label].type != "string") && (labels[label].type != "number")){
// variable exists but not yet evaluated; try to evaluate
var err = lazyEval(labels[label], labels, references, unevalRefs, evalReqs, true);
- if (typeof(err) == typeof("")){ return err; }
+ if (typeof(err) == typeof("")){ return reportError(err); }
}
if ((labels[label].type == "string") || (labels[label].type == "number")){
// variable fully evaluated; substitute it in
@@ -541,7 +554,7 @@ var ExExp = ExExp || {
var newUneval = [];
while (unevalRefs.length > 0){
var r = lazyEval(unevalRefs.shift(), labels, references, unevalRefs, evalReqs, true);
- if (typeof(r) == typeof("")){ return err; }
+ if (typeof(r) == typeof("")){ return reportError(err); }
if ((r.type == "string") || (r.type == "number")){ doSubstitution = true; }
else{ newUneval.push(r); }
}
@@ -563,25 +576,18 @@ var ExExp = ExExp || {
for (var i = 0; i < evalReqs.length; i++){
evalResults.push([evalReqs[i], msg.inlinerolls[i].results.total]);
}
- ExExp.sendCommand(chunks, asts, evalResults, inline, from);
+ ExExp.sendCommand(chunks, asts, evalResults, inline, from, labels);
};
sendChat(from, cmd, evalRecurse);
}
if (asts.length > 0){
// need to finish evaluating some ASTs; recurse directly
- return ExExp.sendCommand(chunks, asts, [], inline, from)
+ return ExExp.sendCommand(chunks, asts, [], inline, from, labels)
}
// if we got here, we're done evaluating everything; submit results via sendChat
sendChat(from, chunks.join(""));
},
- write: function(s, who, style, from){
- if (who){
- who = "/w " + who.split(" ", 1)[0] + " ";
- }
- sendChat(from, who + s.replace(//g, ">").replace(/\n/g, "
"));
- },
-
showHelp: function(who){
var helpMsg = "";
helpMsg += "Usage: !exroll command\n";
@@ -661,14 +667,14 @@ var ExExp = ExExp || {
}
}
chunks.push(state.s);
- ExExp.sendCommand(chunks, asts, [], inline, msg.who);
+ ExExp.sendCommand(chunks, asts, [], inline, msg.who, {});
},
handleChatMessage: function(msg){
if (msg.type != "api"){ return; }
if ((msg.content.indexOf("!exroll") != 0) && (msg.content.indexOf("!extend") != 0)){ return; }
- return ExExp.handleCronMessage(msg.content.split(" "), msg);
+ return ExExp.handleExExpMessage(msg.content.split(" "), msg);
},
registerExExp: function(){
diff --git a/ExtendedExpressions/package.json b/ExtendedExpressions/package.json
index 545b353f18..e9bd8e39df 100644
--- a/ExtendedExpressions/package.json
+++ b/ExtendedExpressions/package.json
@@ -1,6 +1,6 @@
{
"name": "ExtendedExpressions",
- "version": "0.1",
+ "version": "0.3",
"description": "Extended roll expression syntax, supporting conditionals, variable references, bitwise operators, and more.",
"authors": "manveti",
"roll20userid": "503018",
diff --git a/cron/Help.txt b/cron/Help.txt
index 9ed07782f5..ee0310b04c 100644
--- a/cron/Help.txt
+++ b/cron/Help.txt
@@ -87,8 +87,8 @@ Examples:
roll each round.
!cron -f Nanny -t 23:00 Bedtime for sleepy-head. Time to wrap things up.
- Be aware that the time zone is based on the API server, not the client who
- runs the command.
+ Be aware that the time zone is GMT, not local time of the client who runs
+ the command.
!cron -a 30 Hey! It's 30 seconds later than when I typed this.
Probably more useful with larger delay amounts.
@@ -101,6 +101,6 @@ Examples:
around commands which contain tokens which are valid !cron arguments (e.g.
"-R"). Without the quotes, this will immediately remove job 42.
-!cron -a 1 &{template:default} {{name=Test}} {{foo=bar}}
- Note that the "&" must be "&", otherwise the "&{template:default}" will
- be consumed by the chat system before the message is passed to the script.
+!cron -a 1 &{template:default} {{name=Test}} {{foo=bar}}
+ As of version 0.5, templates are handled correctly, and do not need (or
+ support) &-escaping.
diff --git a/cron/package.json b/cron/package.json
index c40cbad8ed..4ef756bd1e 100644
--- a/cron/package.json
+++ b/cron/package.json
@@ -1,6 +1,6 @@
{
"name": "cron",
- "version": "0.4",
+ "version": "0.5",
"description": "Schedule (possibly recurring) commands to run at some point in the future.",
"authors": "manveti",
"roll20userid": "503018",