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

[Help] Blood and Honor script

1457484474
Alex C.
Plus
Marketplace Creator
Decided to give this one a go tonight but I keep running into an Unexpected String error. I assume it's conflicting with another script, but I'm not sure which one. Any ideas? I'm running trackerjacker, an auto torch script, isGM, group initiative, visualalert, aurahealth, herbalism, and a soundfx script. Here is my code: ///////////////////////////////////////////////// /***********************************************/ var BloodAndHonor = { author: { name: "John C." || "Echo" || "SplenectomY", company: "Team Asshat" || "The Alehounds", contact: "<a href="mailto:echo@TeamAsshat.com" rel="nofollow">echo@TeamAsshat.com</a>" }, version: "0.8.2", // The Aaron - Patched for playerIsGM(), createObj(), and randomInteger() crash. gist: "<a href="https://gist.github.com/SplenectomY/097dac3e427ec50f32c9" rel="nofollow">https://gist.github.com/SplenectomY/097dac3e427ec50f32c9</a>", forum: "<a href="https://app.roll20.net/forum/post/1477230/" rel="nofollow">https://app.roll20.net/forum/post/1477230/</a>", wiki: "<a href="https://wiki.roll20.net/Script:Blood_And_Honor:_Automatic_blood_spatter,_pooling_and_trail_effects" rel="nofollow">https://wiki.roll20.net/Script:Blood_And_Honor:_Automatic_blood_spatter,_pooling_and_trail_effects</a>", /***********************************************/ ///////////////////////////////////////////////// // This value should match the size of a standard grid in your campaign // Default is 70 px x 70 px square, Roll20's default. tokenSize: 70, // If you have it installed, this will plug in TheAaron's isGM auth module, // which will make it so only the GM can use the !clearblood command // Change to "true" if you want to check for authorization // NOTE: Changed this to use the now built in playerIsGM() useIsGM: false, // YOU MUST ADD YOUR OWN SPATTERS AND POOLS TO YOUR LIBRARY // AND GET THE IMAGE LINK VIA YOUR WEB BROWSER. // FOLLOW THE INSTRUCTIONS HERE: // <a href="https://wiki.roll20.net/API:Objects#imgsrc_and_av" rel="nofollow">https://wiki.roll20.net/API:Objects#imgsrc_and_av</a>... // You can add as many as you'd like to either category. // Spatters are also used for blood trails. spatters: [ "<a href="https://s3.amazonaws.com/files.d20.io/images/16989368/3zJwmg-z_fDNePwqBsFKtQ/thumb.png?1457411652" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/16989368/3zJwmg-z_fDNePwqBsFKtQ/thumb.png?1457411652</a>" "<a href="https://s3.amazonaws.com/files.d20.io/images/16989377/axkK2CUvmXFnZTsK3WZIXw/thumb.png?1457411687" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/16989377/axkK2CUvmXFnZTsK3WZIXw/thumb.png?1457411687</a>" "<a href="https://s3.amazonaws.com/files.d20.io/images/16989402/Cxp_NLFijzn4NQwRN-6HCg/thumb.png?1457411746" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/16989402/Cxp_NLFijzn4NQwRN-6HCg/thumb.png?1457411746</a>" "<a href="https://s3.amazonaws.com/files.d20.io/images/16989374/UP1U0zWDXKAgR5H5gf5Icw/thumb.png?1457411677" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/16989374/UP1U0zWDXKAgR5H5gf5Icw/thumb.png?1457411677</a>", ], pools: [ "<a href="https://s3.amazonaws.com/files.d20.io/images/16989395/ua8sNd6pyQOErAfMEKvWMA/thumb.png?1457411731" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/16989395/ua8sNd6pyQOErAfMEKvWMA/thumb.png?1457411731</a>" "<a href="https://s3.amazonaws.com/files.d20.io/images/16989392/S-VmfdwjmwmixbwZ_BzO_Q/thumb.png?1457411718" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/16989392/S-VmfdwjmwmixbwZ_BzO_Q/thumb.png?1457411718</a>" "<a href="https://s3.amazonaws.com/files.d20.io/images/16989383/5wcglJN-vnCIKxaolDViiQ/thumb.png?1457411699" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/16989383/5wcglJN-vnCIKxaolDViiQ/thumb.png?1457411699</a>" "<a href="https://s3.amazonaws.com/files.d20.io/images/16989370/Lrr1jGktAxz8AJB-x8xmOA/thumb.png?1457411664" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/16989370/Lrr1jGktAxz8AJB-x8xmOA/thumb.png?1457411664</a>", ], chooseBlood: function chooseBlood(type) { if (type == "spatter") return BloodAndHonor.spatters[randomInteger(BloodAndHonor.spatters.length) - 1]; if (type == "pool") return BloodAndHonor.pools[randomInteger(BloodAndHonor.pools.length) - 1]; }, getOffset: function getOffset() { if (randomInteger(2) == 1) return 1; else return -1; }, bloodColor: function bloodColor(gmnotes) { if (gmnotes.indexOf("bloodcolor_purple") !== -1) return "#0000ff"; if (gmnotes.indexOf("bloodcolor_blue") !== -1) return "#00ffff"; if (gmnotes.indexOf("bloodcolor_orange") !== -1) return "#ffff00"; else return "transparent" }, createBlood: function createBlood(gPage_id,gLeft,gTop,gWidth,gType,gColor) { gLeft = gLeft + (randomInteger(Math.floor(gWidth / 2)) * BloodAndHonor.getOffset()); gTop = gTop + (randomInteger(Math.floor(gWidth / 2)) * BloodAndHonor.getOffset()); setTimeout(function(){ toFront(createObj("graphic",{ imgsrc: gType, gmnotes: "blood", pageid: gPage_id, left: gLeft, tint_color: gColor, top: gTop, rotation: randomInteger(360) - 1, width: gWidth, height: gWidth, layer: "map" })); },50); }, timeout: 0, onTimeout: function theFinalCountdown() { if (BloodAndHonor.timeout &gt; 0) { BloodAndHonor.timeout--; } else { return; } } }; on("ready", function(obj) { setInterval(function(){BloodAndHonor.onTimeout()},1000); on("change:graphic:bar3_value", function(obj, prev) { if (obj.get("bar3_max") === "" || obj.get("layer") != "objects" || (obj.get("gmnotes")).indexOf("noblood") !== -1) return; // Create spatter near token if "bloodied". // Chance of spatter depends on severity of damage else if (obj.get("bar3_value") &lt;= obj.get("bar3_max") / 2 && prev["bar3_value"] &gt; obj.get("bar3_value") && obj.get("bar3_value") &gt; 0) { var m=parseInt(obj.get('bar3_max'),10)||1, v=parseInt(obj.get('bar3_value'),10)||1, r=randomInteger(m); if (r&gt;v) { var bloodMult = 1 + ((obj.get("bar3_value") - prev["bar3_value"]) / obj.get("bar3_max")); BloodAndHonor.createBlood(obj.get("_pageid"), obj.get("left"), obj.get("top"), Math.floor(BloodAndHonor.tokenSize * bloodMult), BloodAndHonor.chooseBlood("spatter"), BloodAndHonor.bloodColor(obj.get("gmnotes"))); } } // Create pool near token if health drops below 1. else if (obj.get("bar3_value") &lt;= 0) { BloodAndHonor.createBlood(obj.get("_pageid"), obj.get("left"), obj.get("top"), Math.floor(BloodAndHonor.tokenSize * 1.5), BloodAndHonor.chooseBlood("pool"), BloodAndHonor.bloodColor(obj.get("gmnotes"))); } }); //Make blood trails, chance goes up depending on how injured a token is on("change:graphic:lastmove", function(obj) { if (BloodAndHonor.timeout == 0) { if (obj.get("bar3_value") &lt;= obj.get("bar3_max") / 2 && (obj.get("gmnotes")).indexOf("noblood") == -1) { var m=parseInt(obj.get('bar3_max'),10)||1, v=parseInt(obj.get('bar3_value'),10)||1, r=randomInteger(m); if (r&gt;v) { BloodAndHonor.createBlood(obj.get("_pageid"), obj.get("left"), obj.get("top"), Math.floor(BloodAndHonor.tokenSize / 2), BloodAndHonor.chooseBlood("spatter"), BloodAndHonor.bloodColor(obj.get("gmnotes"))); BloodAndHonor.timeout += 2; } } } }); on("chat:message", function(msg) { if (msg.type == "api" && msg.content.indexOf("!clearblood") !== -1) { if (BloodAndHonor.useIsGM && !playerIsGM(msg.playerid)) { sendChat(msg.who,"/w " + msg.who + " You are not authorized to use that command!"); return; } else { objects = filterObjs(function(obj) { if(obj.get("type") == "graphic" && obj.get("gmnotes") == "blood") return true; else return false; }); _.each(objects, function(obj) { obj.set("left",0); obj.set("top",0); }); } } }); });
Hi Alex. I had the same problem with another script. What I did was to create a fresh copy of my game and then reinstall all the scripts. For some reason that solved the problem. No idea why. :D
1457507660
The Aaron
Pro
API Scripter
It looks like when you added the image URLs, you left off the commas: spatters: [ "<a href="https://s3.amazonaws.com/files.d20.io/images/16989368/3zJwmg-z_fDNePwqBsFKtQ/thumb.png?1457411652&quot;,/*" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/16989368/3zJwmg-z_fDNePwqBsFKtQ/thumb.png?1457411652",/*</a> &lt;= Comma */ "<a href="https://s3.amazonaws.com/files.d20.io/images/16989377/axkK2CUvmXFnZTsK3WZIXw/thumb.png?1457411687&quot;,/*" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/16989377/axkK2CUvmXFnZTsK3WZIXw/thumb.png?1457411687",/*</a> &lt;= Comma */ "<a href="https://s3.amazonaws.com/files.d20.io/images/16989402/Cxp_NLFijzn4NQwRN-6HCg/thumb.png?1457411746&quot;,/*" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/16989402/Cxp_NLFijzn4NQwRN-6HCg/thumb.png?1457411746",/*</a> &lt;= Comma */ "<a href="https://s3.amazonaws.com/files.d20.io/images/16989374/UP1U0zWDXKAgR5H5gf5Icw/thumb.png?1457411677" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/16989374/UP1U0zWDXKAgR5H5gf5Icw/thumb.png?1457411677</a>" ], pools: [ "<a href="https://s3.amazonaws.com/files.d20.io/images/16989395/ua8sNd6pyQOErAfMEKvWMA/thumb.png?1457411731&quot;,/*" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/16989395/ua8sNd6pyQOErAfMEKvWMA/thumb.png?1457411731",/*</a> &lt;= Comma */ "<a href="https://s3.amazonaws.com/files.d20.io/images/16989392/S-VmfdwjmwmixbwZ_BzO_Q/thumb.png?1457411718&quot;,/*" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/16989392/S-VmfdwjmwmixbwZ_BzO_Q/thumb.png?1457411718",/*</a> &lt;= Comma */ "<a href="https://s3.amazonaws.com/files.d20.io/images/16989383/5wcglJN-vnCIKxaolDViiQ/thumb.png?1457411699&quot;,/*" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/16989383/5wcglJN-vnCIKxaolDViiQ/thumb.png?1457411699",/*</a> &lt;= Comma */ "<a href="https://s3.amazonaws.com/files.d20.io/images/16989370/Lrr1jGktAxz8AJB-x8xmOA/thumb.png?1457411664" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/16989370/Lrr1jGktAxz8AJB-x8xmOA/thumb.png?1457411664</a>" ], Adding them in should fix it.
1457507740
The Aaron
Pro
API Scripter
Peter Bergholtz said: Hi Alex. I had the same problem with another script. What I did was to create a fresh copy of my game and then reinstall all the scripts. For some reason that solved the problem. No idea why. :D You probably were actually having the unexpected identifier error , where a script doesn't end in a ; and changing the order suddenly fixes things because the concatenation order is different. &nbsp;=D
The Aaron said: Peter Bergholtz said: Hi Alex. I had the same problem with another script. What I did was to create a fresh copy of my game and then reinstall all the scripts. For some reason that solved the problem. No idea why. :D You probably were actually having the unexpected identifier error , where a script doesn't end in a ; and changing the order suddenly fixes things because the concatenation order is different. &nbsp;=D You scare me, you know that? :)
1457509849
The Aaron
Pro
API Scripter
BWAHAHAHAHA. :)
1457573461
Alex C.
Plus
Marketplace Creator
The Aaron said: It looks like when you added the image URLs, you left off the commas: spatters: [ "<a href="https://s3.amazonaws.com/files.d20.io/images/16989368/3zJwmg-z_fDNePwqBsFKtQ/thumb.png?1457411652&quot;,/*" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/16989368/3zJwmg-z_fDNePwqBsFKtQ/thumb.png?1457411652",/*</a> &lt;= Comma */ "<a href="https://s3.amazonaws.com/files.d20.io/images/16989377/axkK2CUvmXFnZTsK3WZIXw/thumb.png?1457411687&quot;,/*" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/16989377/axkK2CUvmXFnZTsK3WZIXw/thumb.png?1457411687",/*</a> &lt;= Comma */ "<a href="https://s3.amazonaws.com/files.d20.io/images/16989402/Cxp_NLFijzn4NQwRN-6HCg/thumb.png?1457411746&quot;,/*" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/16989402/Cxp_NLFijzn4NQwRN-6HCg/thumb.png?1457411746",/*</a> &lt;= Comma */ "<a href="https://s3.amazonaws.com/files.d20.io/images/16989374/UP1U0zWDXKAgR5H5gf5Icw/thumb.png?1457411677" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/16989374/UP1U0zWDXKAgR5H5gf5Icw/thumb.png?1457411677</a>" ], pools: [ "<a href="https://s3.amazonaws.com/files.d20.io/images/16989395/ua8sNd6pyQOErAfMEKvWMA/thumb.png?1457411731&quot;,/*" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/16989395/ua8sNd6pyQOErAfMEKvWMA/thumb.png?1457411731",/*</a> &lt;= Comma */ "<a href="https://s3.amazonaws.com/files.d20.io/images/16989392/S-VmfdwjmwmixbwZ_BzO_Q/thumb.png?1457411718&quot;,/*" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/16989392/S-VmfdwjmwmixbwZ_BzO_Q/thumb.png?1457411718",/*</a> &lt;= Comma */ "<a href="https://s3.amazonaws.com/files.d20.io/images/16989383/5wcglJN-vnCIKxaolDViiQ/thumb.png?1457411699&quot;,/*" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/16989383/5wcglJN-vnCIKxaolDViiQ/thumb.png?1457411699",/*</a> &lt;= Comma */ "<a href="https://s3.amazonaws.com/files.d20.io/images/16989370/Lrr1jGktAxz8AJB-x8xmOA/thumb.png?1457411664" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/16989370/Lrr1jGktAxz8AJB-x8xmOA/thumb.png?1457411664</a>" ], Adding them in should fix it. I looked at it a dozen times before posting and totally overlooked those commas. It did the trick ... thanks Aaron!
1457584790
The Aaron
Pro
API Scripter
No problem! &nbsp;Happy rolling!