
I got an API from another user who using this same API in his game, It is meant to auto subtract or add to the bars. ( 1, 2 and 3) But when I put it in as a script. I get this error. /home/symbly/www/d20-api-server/node_modules/firebase/lib/firebase-node.js:1
orts, require, module, __filename, __dirname) { function g(a){throw a;}var j=v
^
Error: Firebase.update failed: First argument contains NaN in property 'bar1_value'
at Error (<anonymous>)
at Ba (/home/symbly/www/d20-api-server/node_modules/firebase/lib/firebase-node.js:9:186)
at Ba (/home/symbly/www/d20-api-server/node_modules/firebase/lib/firebase-node.js:10:207)
at Aa (/home/symbly/www/d20-api-server/node_modules/firebase/lib/firebase-node.js:8:462)
at Ea (/home/symbly/www/d20-api-server/node_modules/firebase/lib/firebase-node.js:10:403)
at H.J.update (/home/symbly/www/d20-api-server/node_modules/firebase/lib/firebase-node.js:146:318)
at TrackedObj._doSave ( Here is the API as well. // USER CONFIGURATION
// Set the PREVENT_OVERMAX variable to true to prevent the value of a
// token's bar from being greater than its max value. If there is no max
// value set, it will not stop the current bar value from increasing.
var PREVENT_OVERMAX = true;
// Set the ANNOUNCE_CHANGE variable to true to send a message to the chat
// window, announcing which token gained or lost points on a bar.
var ANNOUNCE_CHANGE = true;
// Stops the bar at zero instead of allowing it to go negative.
var STOP_AT_ZERO = true;
// BAR CONFIGURATION - These are used to identify which bar to adjust. The
// example below was made for a specific Roll20 user's preferences. These
// bar keys must be lowercase, though players can use any case in their
// macro since the script converts everything to lower case.
var Bar1Key = "h"; // (H)ealth
var Bar2Key = "f"; // (F)atigue
var Bar3Key = "m"; // (M)ana
// BAR NAMES - These names are used if ANNOUNCE_CHANGE is set to true. The
// format of the annoucement is: Name gained/lost # BarName.
var BarNames = ["hit points", "fatigue", "mana"];
on("chat:message", function(msg) {
// Exit if not an api command
if (msg.type != "api") return;
// Get the API Command
msg.who = msg.who.replace(" (GM)", "");
msg.content = msg.content.replace("(GM) ", "");
var n = msg.content.split(" ");
var command = n[0].toLowerCase();
// CSS Stuff...
// Target.get("name") + " lost <span title='" + Expression + "' class='a inlinerollresult showtip tipsy-n'" +
var AddStyle = "display: inline-block; text-align: center; min-width: 1.75em; font-size: 1em; font-weight: bold; color:#040; background-color: #8C8; border: 1px solid #040; padding: -1px 2px; border-radius: 3px;";
var MinusStyle = "display: inline-block; text-align: center; min-width: 1.75em; font-size: 1em; font-weight: bold; color:#600; background-color: #FAA; border: 1px solid #600; padding: -1px 2px; border-radius: 3px;";
if (command == "!alter") {
// Define variables...
var Target = getObj("graphic", n[1]);
var Bar = 0;
Bar = (n[2].toLowerCase() == Bar1Key) ? 1 : 0;
Bar = (n[2].toLowerCase() == Bar2Key) ? 2 : Bar;
Bar = (n[2].toLowerCase() == Bar3Key) ? 3 : Bar;
if (Bar == 0) {
sendChat("ERROR", "/w " + msg.who + " That is not a valid bar. Please use the first letter as follows: H(ealth), F(atigue), or M(ana).");
return;
}
var AlterValue = n[3];
var TargetBarCurrent = parseInt(Target.get("bar" + Bar + "_value"));
var TargetBarMax = parseInt(Target.get("bar" + Bar + "_max"));
var StartingValue = TargetBarCurrent;
// Check for a + or - sign at the start of the AlterValue...
var OperandCheck = AlterValue.charAt(0);
var DoubleOperandCheck = AlterValue.charAt(1);
if (DoubleOperandCheck === "+" || DoubleOperandCheck === "-") {
AlterValue = AlterValue.substring(2);
} else if (OperandCheck === "+" || OperandCheck === "-") {
AlterValue = AlterValue.substring(1);
}
var Expression = AlterValue;
if (AlterValue.indexOf("d") != -1) {
sendChat("", "/r " + AlterValue, function(outs) {
AlterValue = parseInt(JSON.parse(outs[0].content).total);
var Tooltip = "Rolling " + Expression + " = " + AlterValue + "' class='a inlinerollresult showtip tipsy-n'";
if (OperandCheck != "-") {
// ADD TO BAR
if (PREVENT_OVERMAX) {
AlterValue = (AlterValue + TargetBarCurrent > TargetBarMax) ? TargetBarMax - TargetBarCurrent : AlterValue;
}
Target.set("bar" + Bar + "_value", TargetBarCurrent += AlterValue);
if (ANNOUNCE_CHANGE) sendChat("", Target.get("name") + " gains <span title='" + Tooltip + "' style='" + AddStyle + "'>" + AlterValue + "</span> " + BarNames[Bar-1] + ".");
} else {
// SUBTRACT FROM BAR
if (STOP_AT_ZERO && (TargetBarCurrent - AlterValue < 0)) {
AlterValue = TargetBarCurrent;
}
Target.set("bar" + Bar + "_value", TargetBarCurrent -= AlterValue);
if (ANNOUNCE_CHANGE) sendChat("", Target.get("name") + " lost <span title='" + Tooltip + "' style='" + " ' style='" + MinusStyle + "'>" + AlterValue + "</span> " + BarNames[Bar-1] + ".");
}
});
} else {
AlterValue = parseInt(AlterValue);
var Tooltip = "Rolling " + Expression + " = " + AlterValue + "' class='a inlinerollresult showtip tipsy-n'";
if (OperandCheck != "-") {
// ADD TO BAR
if (PREVENT_OVERMAX) {
AlterValue = (AlterValue + TargetBarCurrent > TargetBarMax) ? TargetBarMax - TargetBarCurrent : AlterValue;
}
Target.set("bar" + Bar + "_value", TargetBarCurrent += AlterValue);
if (ANNOUNCE_CHANGE) sendChat("", Target.get("name") + " gains <span title='" + Tooltip + "' style='" + AddStyle + "'>" + AlterValue + "</span> " + BarNames[Bar-1] + ".");
} else {
// SUBTRACT FROM BAR
if (STOP_AT_ZERO && (TargetBarCurrent - AlterValue < 0)) {
AlterValue = TargetBarCurrent;
}
Target.set("bar" + Bar + "_value", TargetBarCurrent -= AlterValue);
if (ANNOUNCE_CHANGE) sendChat("", Target.get("name") + " lost <span title='" + Tooltip + "' style='" + MinusStyle + "'>" + AlterValue + "</span> " + BarNames[Bar-1] + ".");
}
}
}
});
The only thing I can think of is that it interferes with another of my API. Here are the others I am using. Token Collision Vector Math Its a Trap Crit Fail Announcer Token Name Number Power Cards 2 Token Mod IsGM Torch None of the 9 above API are altered in any way. The API I posted is not listed in the 9 above. It is altered, but not by me. Either there is a coding error, or the API hates another of my installed API. Thanks for the help, Ryeaa