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 issue

I have copied the blood and honor script and added my blood images as instructed.  The normal blood splatter works fine, but when the creature is reduced to 0hp or less the script stops working and I get the error: undefined:1370 throw "Error: toFront() must be given an object either from an event or ge ^ Error: toFront() must be given an object either from an event or getObj() or similar. I wish I was smarter, but I'm just getting started working with API.  I didn't modify this script, except that I added blood images.   Does anyone have any ideas? Thank you.
Not to hijack this thread but I am also receiving an issue with it, not the same as the OP but I figured since it is the same script I wouldn't make a new thread. Below is my error message that I receive, as you can see it doesn't actually give me an error message... It just displays nothing but it still stops my script and I can't get it to work in game. I've tried repasting the script over from scratch and only adding in the pictures as mentioned above but it still doesn't work... Any advice? (Also you will find my script below as well) *Error Code* "The sandbox attempted to start but no scripts were found for your game. Don't worry, this is perfectly normal since you probably haven't created any yet. Just write a script in the box above and click "Save Script". Your scripts are currently disabled due to an error that was detected. Please make appropriate changes to your scripts and click the "Save Script" button and we'll attempt to start running them again. More info... For reference, the error message generated was: " *Script*  ///////////////////////////////////////////////// /***********************************************/ 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", 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 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_avatar_property_restrictions" rel="nofollow">https://wiki.roll20.net/API:Objects#imgsrc_and_avatar_property_restrictions</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/11125569/lKydlVOaIhh6SBjPBaFFDw/thumb.png?1438118751" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/11125569/lKydlVOaIhh6SBjPBaFFDw/thumb.png?1438118751</a> ", " <a href="https://s3.amazonaws.com/files.d20.io/images/11125573/wabPs6YckbTfnqRhdSIajw/thumb.png?1438118761" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/11125573/wabPs6YckbTfnqRhdSIajw/thumb.png?1438118761</a> ", " <a href="https://s3.amazonaws.com/files.d20.io/images/11125519/j8E1aqD-GE-5h9XyfpnVSw/thumb.png?1438118577" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/11125519/j8E1aqD-GE-5h9XyfpnVSw/thumb.png?1438118577</a> ", " <a href="https://s3.amazonaws.com/files.d20.io/images/11125566/Tj4_wCXribzZ0ucVCNE9wg/thumb.png?1438118746" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/11125566/Tj4_wCXribzZ0ucVCNE9wg/thumb.png?1438118746</a> ", ], pools: [ " <a href="https://s3.amazonaws.com/files.d20.io/images/11125571/POIhC2ZyJEIoYzeZcKLxpA/thumb.png?1438118757" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/11125571/POIhC2ZyJEIoYzeZcKLxpA/thumb.png?1438118757</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(fixedCreateObj("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; } } }; fixedCreateObj = (function () { return function () { var obj = createObj.apply(this, arguments); if (obj && !obj.fbpath) { obj.fbpath = obj.changed._fbpath.replace(/([^\/]*\/){4}/, "/"); } return obj; }; }()); 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) { if (randomInteger(obj.get("bar3_max")) &gt; obj.get("bar3_value")) { 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) { if (randomInteger(obj.get("bar3_max")) &gt; obj.get("bar3_value")) { 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 && !isGM(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); }); } } }); });
Andrew K. said: spatters: [ " <a href="https://s3.amazonaws.com/files.d20.io/images/11125569/lKydlVOaIhh6SBjPBaFFDw/thumb.png?1438118751" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/11125569/lKydlVOaIhh6SBjPBaFFDw/thumb.png?1438118751</a> ", " <a href="https://s3.amazonaws.com/files.d20.io/images/11125573/wabPs6YckbTfnqRhdSIajw/thumb.png?1438118761" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/11125573/wabPs6YckbTfnqRhdSIajw/thumb.png?1438118761</a> ", " <a href="https://s3.amazonaws.com/files.d20.io/images/11125519/j8E1aqD-GE-5h9XyfpnVSw/thumb.png?1438118577" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/11125519/j8E1aqD-GE-5h9XyfpnVSw/thumb.png?1438118577</a> ", " <a href="https://s3.amazonaws.com/files.d20.io/images/11125566/Tj4_wCXribzZ0ucVCNE9wg/thumb.png?1438118746" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/11125566/Tj4_wCXribzZ0ucVCNE9wg/thumb.png?1438118746</a> ", ], pools: [ " <a href="https://s3.amazonaws.com/files.d20.io/images/11125571/POIhC2ZyJEIoYzeZcKLxpA/thumb.png?1438118757" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/11125571/POIhC2ZyJEIoYzeZcKLxpA/thumb.png?1438118757</a> ", ], Have either of you tried removing the comma after the last image url for both splatters and pools? That has given me issues before.&nbsp;
Glenn, &nbsp; &nbsp; Just gave it a try, didn't work for me, still getting that error on pool only.
Andrew, &nbsp; &nbsp; are you using the Arron's GM module? &nbsp;If not, put // in front of&nbsp;useIsGM: false, Referencing this when I wasn't using it caused that same error.
1438383432

Edited 1438383461
Lithl
Pro
Sheet Author
API Scripter
Andrew K. said: The sandbox attempted to start but no scripts were found for your game. Don't worry, this is perfectly normal since you probably haven't created any yet. Just write a script in the box above and click "Save Script". This error is not caused by a problem with the script itself. I am not entirely certain what circumstances cause the campaign to fail to see the script(s) you have installed, but I do know it's nothing about the contents of the script(s).
Have you contacted the script author?
Anthony M. said: Andrew, &nbsp; &nbsp; are you using the Arron's GM module? &nbsp;If not, put // in front of&nbsp;useIsGM: false, Referencing this when I wasn't using it caused that same error. Hey guys so this actually worked for me. I tried Deleting the Commas as Glenn H. said but it was still returning the same error. Now I did the // in front of uselsGM: false as Anthony suggested and that helped me out. I also switched my bars around in my game so I just edited &nbsp;the bar value that it was selecting to the one I needed (this is after I made sure it worked) and it still works. Script is below, thanks for the help guys!!! I am so excited to get this working for my next session!! :D ///////////////////////////////////////////////// /***********************************************/ 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", 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 // 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/11125569/lKydlVOaIhh6SBjPBaFFDw/thumb.png?1438118751" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/11125569/lKydlVOaIhh6SBjPBaFFDw/thumb.png?1438118751</a>", "<a href="https://s3.amazonaws.com/files.d20.io/images/11125573/wabPs6YckbTfnqRhdSIajw/thumb.png?1438118761" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/11125573/wabPs6YckbTfnqRhdSIajw/thumb.png?1438118761</a>", "<a href="https://s3.amazonaws.com/files.d20.io/images/11125519/j8E1aqD-GE-5h9XyfpnVSw/thumb.png?1438118577" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/11125519/j8E1aqD-GE-5h9XyfpnVSw/thumb.png?1438118577</a>", "<a href="https://s3.amazonaws.com/files.d20.io/images/11125566/Tj4_wCXribzZ0ucVCNE9wg/thumb.png?1438118746" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/11125566/Tj4_wCXribzZ0ucVCNE9wg/thumb.png?1438118746</a>" ], pools: [ "<a href="https://s3.amazonaws.com/files.d20.io/images/11125571/POIhC2ZyJEIoYzeZcKLxpA/thumb.png?1438118757" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/11125571/POIhC2ZyJEIoYzeZcKLxpA/thumb.png?1438118757</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(fixedCreateObj("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; } } }; fixedCreateObj = (function () { return function () { var obj = createObj.apply(this, arguments); if (obj && !obj.fbpath) { obj.fbpath = obj.changed._fbpath.replace(/([^\/]*\/){4}/, "/"); } return obj; }; }()); on("ready", function(obj) { setInterval(function(){BloodAndHonor.onTimeout()},1000); on("change:graphic:bar1_value", function(obj, prev) { if (obj.get("bar1_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("bar1_value") &lt;= obj.get("bar1_max") / 2 && prev["bar1_value"] &gt; obj.get("bar1_value") && obj.get("bar1_value") &gt; 0) { if (randomInteger(obj.get("bar1_max")) &gt; obj.get("bar1_value")) { var bloodMult = 1 + ((obj.get("bar1_value") - prev["bar1_value"]) / obj.get("bar1_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("bar1_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("bar1_value") &lt;= obj.get("bar1_max") / 2 && (obj.get("gmnotes")).indexOf("noblood") == -1) { if (randomInteger(obj.get("bar1_max")) &gt; obj.get("bar3_value")) { 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 && !isGM(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); }); } } }); });
1438633070
DK Heinrich
Marketplace Creator
Sheet Author
being 99% script illiterate - what would I need to change to have it read bar3 for higher numbers instead of lower numbers to trigger the splatters. My system has additive damage (as opposed to subtracting HP) that is compared to a health score. If your damage &gt;= health score you fall over. Think reverse of HP.&nbsp; I think its somewhere from 'setInterval(function(){BloodAndHonor.onTimeout()},1000);' down... but unsure what to do where. Thanks!
1438675895
Kryx
Pro
Sheet Author
API Scripter
You'll have to change several lines for that. Mostly reversing the greater than/less than symbols. But you'll also have to change 0 to the max.
1438695025
DK Heinrich
Marketplace Creator
Sheet Author
Mark said: ... But you'll also have to change 0 to the max. &nbsp;obj.get("bar1_max") would be the way to find the max instead of 0?
1438695116
Kryx
Pro
Sheet Author
API Scripter
DK Heinrich said: &nbsp;obj.get("bar1_max") would be the way to find the max instead of 0? Yup.
1438700932
DK Heinrich
Marketplace Creator
Sheet Author
Mark said: DK Heinrich said: &nbsp;obj.get("bar1_max") would be the way to find the max instead of 0? Yup. Thanks.
1438708605

Edited 1438709049
DK Heinrich
Marketplace Creator
Sheet Author
Below is section I changed. Bold is my changes. I also added my image files (to my library and to the script) Getting 'Unexpected token ILLEGAL' - ideas? Getting 'Unexpected token ILLEGAL' again. I think it went away from inactivity and on restart it has same issue. // Create spatter near token if "bloodied". // Chance of spatter depends on severity of damage else if (obj.get("bar1_value") &gt; = obj.get("bar1_max") / 2 && prev["bar1_value"] &lt; obj.get("bar1_value") && obj.get("bar1_value") &nbsp;&gt; &nbsp; obj.get("bar1_max") ) { if (randomInteger(obj.get("bar1_max")) &gt; obj.get("bar1_value")) { var bloodMult = 1 + ((obj.get("bar1_value") - prev["bar1_value"]) / obj.get("bar1_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("bar1_value") &gt; = obj.get("bar1_max") ) { 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("bar1_value") &gt; = obj.get("bar1_max") / 2 && (obj.get("gmnotes")).indexOf("noblood") == -1) { if (randomInteger(obj.get("bar1_max")) &gt; obj.get("bar1_value")) { 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;