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

Script Help

in reference to this script: <a href="https://app.roll20.net/forum/post/197725/script-co" rel="nofollow">https://app.roll20.net/forum/post/197725/script-co</a>... I'm trying to get the Status tracker to update dead and bloodied tokens. Bloodied (1/2 HP) is almost working (tints token) but does not add the status icon. Dead is not being applied and the tint is removed.
Michael, Can you provide a snippit of the code you currently have (assuming you have modified it)?
First modification was to change which status Bar is used (from bar1 to bar3) which works. What is not working is the following: StatusTracker.bloodiedMarker = "broken-skull"; //If you want a creature's token to get marked when below 1/2 hp (bar3_value), 'none' for none. StatusTracker.deadMarker = "skull"; //Marker to show if the token is dead (0 bar3_value) and then this part: on("change:graphic", function(obj, prev) { if(obj.get("bar3_max") == "") return; //If bar3_value did not change, exit if(obj.get("bar3_value") == prev["bar3_value"]) return; if(obj.get("bar3_value") &lt;= 0) { obj.set({ tint_color: "transparent", bar3_value: 0, }); StatusTracker.delMarker(obj.id, StatusTracker.bloodiedMarker); StatusTracker.addMarker(obj.id, StatusTracker.deadMarker); } else if(obj.get("bar3_value") &lt;= obj.get("bar3_max") / 2) { obj.set({ tint_color: StatusTracker.bloodiedTintColor, }); StatusTracker.delMarker(obj.id, StatusTracker.deadMarker); StatusTracker.addMarker(obj.id, StatusTracker.bloodiedMarker); } else{ obj.set({ tint_color: "transparent", }); StatusTracker.delMarker(obj.id, StatusTracker.deadMarker); StatusTracker.delMarker(obj.id, StatusTracker.bloodiedMarker); } The tint gets applied when bloodied (&lt;= 1/2 bar3_max) but no status marker is applied.then when bar3 &lt;= 0 it clears the tint and does not apply the dead marker
1399647276

Edited 1399647349
This is similar to what I did... not sure what I did was perfect as I couldn't seem to get the StatusTracker.* personal variables to work well. Also I wanted a 50%, 20%, then dead/dying marker. Here is how I changed that last bit: on("change:graphic:bar3_value", function(obj, prev) { if(obj.get("bar3_max") === "") return; if(obj.get("bar3_value") &lt;= 0) { obj.set({ status_skull: true, tint_color: "#FF0000" }); } else if(obj.get("bar3_value") &lt;= obj.get("bar3_max") / 5) { obj.set({ tint_color: "#FF0000", status_skull: false }); } else if(obj.get("bar3_value") &lt;= obj.get("bar3_max") / 2) { obj.set({ tint_color: "#FF00FF", status_skull: false }); } else{ obj.set({ tint_color: "transparent", status_skull: false }); } }); *Sorry not sure how to do typical [code][/code] with this editor (not sure if it is possible)
Basically at 50% they will tint purple, then at 20% they will turn red, finally at 0 they will stay red but get the "skull" marker.
thanks, I'll try that
AWESOME! fixed and deployed!
Michael, I am very new to Javascript, so it probably isn't pretty or optimal code, but glad it worked :)