Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

This Script No Longer Works

1440622190

Edited 1440640469
Ajax
Pro
I have been using this script for months without a problem, now in every campaign I use it in, it crashes as soon as it loads... The script modifies the bar1 and is used to track hit points, as I stated nothing has been altered and the script no longer works... The script was originally created by Honey Badger... -Ajax // 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] + "."); } } } });
1440640526
The Aaron
Pro
API Scripter
What is the error message?
events.js:72 throw er; // Unhandled 'error' event ^ Error: listen EADDRINUSE at errnoException (net.js:904:11) at Server._listen2 (net.js:1023:19) at listen (net.js:1064:10) at Server.listen (net.js:1132:5) at Sandbox.start (/home/symbly/www/d20-api-server/sandcastle/lib/sandbox.js:35:15) at Object. (/home/symbly/www/d20-api-server/sandcastle/bin/sandcastle.js:11:9) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) -Ajax
1440673444
The Aaron
Roll20 Production Team
API Scripter
Ok. Save the script and try again. That error is something in the sandbox like the Unexpected token s error. It doesn't seem to have anything to do with the scripts involved. 
I have tried that in several of the mods I'm using the script in and it doesn't work in any of them, yet last week they all worked fine, do you think it could have something to do with lag, as for the last week we have been experiencing some serious lag? -Ajax
1440693593

Edited 1440693625
Ajax
Pro
I have re-saved and tested it and now it seems to be working, this makes me think it did have something to do with the lag... Thanks for the tip Aaron... -Ajax