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

Is there a way to make the Blood and Honor Script only appear on the page the players are on?

As the title suggest, Is there a way to make the Blood and Honor Script only appear on the page the players are on? Have blood pools everywhere on all my maps as players take damage, any help would be appreciated thanks!
It is tied to a Token's ID#, so every copy of the token gets treated. On the positive side some of my players like the fact that they are standing in lakes of blood on the splash page. 
1538660941
Jakob
Sheet Author
API Scripter
al e. said: It is tied to a Token's ID#, so every copy of the token gets treated. On the positive side some of my players like the fact that they are standing in lakes of blood on the splash page.  This is factually wrong. Different copies of a token have a different ID.
1538661613
Jakob
Sheet Author
API Scripter
So what you'd want to do is to add an extra check in the script's event handlers. Change line 85 to read if (obj.get("bar3_max") === "" || obj.get("layer") != "objects" || (obj.get("gmnotes")).indexOf("noblood") !== -1 || Campaign().get("playerpageid") !== obj.get("_pageid") ) return; (additions bolded). Similarly, between line 104 and 105, you can add a check: if (Campaign().get("playerpageid") !== obj.get("_pageid")) return;
Maybe i did something wrong but that didn't seem to work Here is my 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.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: 75, // 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_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/47000/thumb.png?1340125245" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/47000/thumb.png?1340125245</a>", "<a href="https://s3.amazonaws.com/files.d20.io/images/90672/r3scoMWkpWvoNaEfpAICBg/thumb.png?1341867698" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/90672/r3scoMWkpWvoNaEfpAICBg/thumb.png?1341867698</a>", "<a href="https://s3.amazonaws.com/files.d20.io/images/14779/thumb.png?1338012034" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/14779/thumb.png?1338012034</a>", "<a href="https://s3.amazonaws.com/files.d20.io/images/13606/thumb.png?1337583610" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/13606/thumb.png?1337583610</a>", "<a href="https://s3.amazonaws.com/files.d20.io/images/36251243/zAOX53-YtVZlQxOsoh3HwQ/thumb.png?1500523234" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/36251243/zAOX53-YtVZlQxOsoh3HwQ/thumb.png?1500523234</a>", "<a href="https://s3.amazonaws.com/files.d20.io/images/5207/thumb.png?1336251796" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/5207/thumb.png?1336251796</a>", "<a href="https://s3.amazonaws.com/files.d20.io/images/13606/thumb.png?1337583610" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/13606/thumb.png?1337583610</a>", "<a href="https://s3.amazonaws.com/files.d20.io/images/208173/7J_yyV1gVqvcv_KL4RCgHQ/thumb.png?1347622486" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/208173/7J_yyV1gVqvcv_KL4RCgHQ/thumb.png?1347622486</a>", "<a href="https://s3.amazonaws.com/files.d20.io/images/36251245/V0d-uXWQl9Mk5hhqqAJsbg/thumb.png?1500523236" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/36251245/V0d-uXWQl9Mk5hhqqAJsbg/thumb.png?1500523236</a>", "<a href="https://s3.amazonaws.com/files.d20.io/images/36251247/b-058yZQWUKDMay8k1Qugg/thumb.png?1500523237" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/36251247/b-058yZQWUKDMay8k1Qugg/thumb.png?1500523237</a>", "<a href="https://s3.amazonaws.com/files.d20.io/images/36251249/arBuDUZR5S1C8-qNu2tsMQ/thumb.png?1500523244" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/36251249/arBuDUZR5S1C8-qNu2tsMQ/thumb.png?1500523244</a>", "<a href="https://s3.amazonaws.com/files.d20.io/images/36251250/QbHYpswy_qvLHqnrVAFCxA/thumb.png?1500523246" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/36251250/QbHYpswy_qvLHqnrVAFCxA/thumb.png?1500523246</a>", "<a href="https://s3.amazonaws.com/files.d20.io/images/36251252/1BsvC-NRSF8xoK39VJB-Nw/thumb.png?1500523247" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/36251252/1BsvC-NRSF8xoK39VJB-Nw/thumb.png?1500523247</a>", "<a href="https://s3.amazonaws.com/files.d20.io/images/36251253/fvXApjI_u4BWrD1ONAL-cg/thumb.png?1500523249" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/36251253/fvXApjI_u4BWrD1ONAL-cg/thumb.png?1500523249</a>", "<a href="https://s3.amazonaws.com/files.d20.io/images/36251256/ysqmn-QmGKXnxi40Bff8uw/thumb.png?1500523251" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/36251256/ysqmn-QmGKXnxi40Bff8uw/thumb.png?1500523251</a>", "<a href="https://s3.amazonaws.com/files.d20.io/images/36251257/7qYWrelcbUVcls2p-3-_rA/thumb.png?1500523253" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/36251257/7qYWrelcbUVcls2p-3-_rA/thumb.png?1500523253</a>", "<a href="https://s3.amazonaws.com/files.d20.io/images/36251259/mZwLiVrfKEGQ1zRKQHo8hA/thumb.png?1500523254" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/36251259/mZwLiVrfKEGQ1zRKQHo8hA/thumb.png?1500523254</a>" ], pools: [ "<a href="https://s3.amazonaws.com/files.d20.io/images/52237/thumb.png?1340356244" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/52237/thumb.png?1340356244</a>", "<a href="https://s3.amazonaws.com/files.d20.io/images/52233/thumb.png?1340356233" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/52233/thumb.png?1340356233</a>", "<a href="https://s3.amazonaws.com/files.d20.io/images/7217/thumb.png?1336399230" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/7217/thumb.png?1336399230</a>", "<a href="https://s3.amazonaws.com/files.d20.io/images/28319/thumb.png?1339333605" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/28319/thumb.png?1339333605</a>", "<a href="https://s3.amazonaws.com/files.d20.io/images/28317/thumb.png?1339333598" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/28317/thumb.png?1339333598</a>", "<a href="https://s3.amazonaws.com/files.d20.io/images/23073/thumb.png?1339067116" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/23073/thumb.png?1339067116</a>", "<a href="https://s3.amazonaws.com/files.d20.io/images/284623/dUJ0UchLsBk8wWtqlzaohw/thumb.png?1350127144" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/284623/dUJ0UchLsBk8wWtqlzaohw/thumb.png?1350127144</a>", "<a href="https://s3.amazonaws.com/files.d20.io/images/36251254/Ah2BxccfDonnIMNGFTCPYQ/thumb.png?1500523250" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/36251254/Ah2BxccfDonnIMNGFTCPYQ/thumb.png?1500523250</a>", "<a href="https://s3.amazonaws.com/files.d20.io/images/36251539/ELiLt5gxC5o5BdeuAP1ULA/thumb.png?1500523767" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/36251539/ELiLt5gxC5o5BdeuAP1ULA/thumb.png?1500523767</a>", "<a href="https://s3.amazonaws.com/files.d20.io/images/36251541/Va36XIxPYB7Ns0IVX2h2KQ/thumb.png?1500523769" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/36251541/Va36XIxPYB7Ns0IVX2h2KQ/thumb.png?1500523769</a>", "<a href="https://s3.amazonaws.com/files.d20.io/images/36251544/krGGMMuqyRHkpElfjISl1g/thumb.png?1500523770" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/36251544/krGGMMuqyRHkpElfjISl1g/thumb.png?1500523770</a>", "<a href="https://s3.amazonaws.com/files.d20.io/images/36251545/7cGMQkbh8FL7CxgEz3pkgw/thumb.png?1500523771" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/36251545/7cGMQkbh8FL7CxgEz3pkgw/thumb.png?1500523771</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_green") !== -1) return "#008000"; if (gmnotes.indexOf("bloodcolor_yellow") !== -1) return "#ffff00"; if (gmnotes.indexOf("bloodcolor_black") !== -1) return "#000000"; 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); let handleBarChange = function(obj, prev) { if (obj.get("bar3_max") === "" || obj.get("layer") != "objects" || (obj.get("gmnotes")).indexOf("noblood") !== -1 || Campaign().get("playerpageid") !== obj.get("_pageid")) 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 &amp;&amp; prev["bar1_value"] &gt; obj.get("bar1_value") &amp;&amp; obj.get("bar1_value") &gt; 0) { var m=parseInt(obj.get('bar1_max'),10)||1, v=parseInt(obj.get('bar1_value'),10)||1, r=randomInteger(m); if (r&gt;v) { 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"))); } }; on("change:graphic:bar1_value", handleBarChange); if('undefined' !== typeof TokenMod &amp;&amp; TokenMod.ObserveTokenChange){ TokenMod.ObserveTokenChange((obj,prev)=&gt;{ if(obj.get('bar1_value')!==prev.bar1_value){ handleBarChange(obj,prev); } }); } //Make blood trails, chance goes up depending on how injured a token is on("change:graphic:lastmove", function(obj) { if (Campaign().get("playerpageid") !== obj.get("_pageid")) return; if (BloodAndHonor.timeout == 0) { if (obj.get("bar1_value") &lt;= obj.get("bar1_max") / 2 &amp;&amp; (obj.get("gmnotes")).indexOf("noblood") == -1) { var m=parseInt(obj.get('bar1_max'),10)||1, v=parseInt(obj.get('bar1_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" &amp;&amp; msg.content.indexOf("!clearblood") !== -1) { if (BloodAndHonor.useIsGM &amp;&amp; !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" &amp;&amp; obj.get("gmnotes") == "blood") return true; else return false; }); _.each(objects, function(obj) { obj.set("left",0); obj.set("top",0); }); } } }); });