... that is good to know, about the forcing string value to a number. now, I had a script, written by someone else, somewhere, that did this pretty much as you seem to intend. I modified it, (for example, it uses bar3 for HP, not bar 1, and bar 2 for spellpoints, or fatigue (the two are tied closely in my version of the game, so it worked quite well.) I switched it to use brown marker for 1/2 life, red marker for 1/4 life, red tint for dying, and black tint for dead. it was not in any way robust though, as it seemed to break every third or fourth combat (just needed a quick reboot of the api and would be good to go again though. On a more personal note, I didn't bother seperating out the PC tokens from NPC's on this, because while a player can see their own tokens bars, I decided that with this script running they didn't need to see the rest of the parties HP bars. It worked quite well, and I didn't get any complaints from my players (none I had to take seriously anyway :P just the usual groan and moan at the start, then they were fine with it) For the record, here is the code, if that gives you any ideas (yes, its VERY messy, but it worked. once. not sure if its broken right now, to be honest, its from an older game of mine, and I stopped using it when i shifted from 3.5 to gurps, where it is unnecessary.) Note: the script locks those Markers, as they become hardwired, so you cannot use them for anything else. Also, like i said, old. uses the old status_redmarker, so hasn't been updated in that long. and also again, this WAS someone elses script, I just modified it to work with my campaign. Hope it helps somehow var deadToken = deadToken || {};
deadToken.unconscious = -1; // set to the number at which a character falls unconscious. deadToken.dyingTint = "#ff0000" // tint color of the token while unconscious. deadToken.deathValue = -10; // set to the number under 0 that a character suffers true death. deadToken.deadTint = "#000000" // the code for the tint when a token is truly dead.
deadTokenCONFIG = [ {barId: 3, barRatio: .5, status: "brownmarker", whenLow: true},//lets you know when bar3 falls below 1/2 max {barId: 3, barRatio: .25, status: "redmarker", whenLow: true},//lets you know when bar3 falls below 1/4 max {barId: 2, barRatio: .5, status: "bluemarker", whenLow: true},// lets you know when bar2 falls below 1/2 max {barId: 2, barRatio: .25, status: "purplemarker", whenLow: true}];// lets you know when bar2 falls below 1/4 max
on("change:token", function(obj) { deadTokenCONFIG.forEach(function(opts) { var maxValue = parseInt(obj.get("bar" + opts.barId + "_max")); var curValue = parseInt(obj.get("bar" + opts.barId + "_value")); //log(opts.barId + ": " + curValue + "/" + maxValue); if (maxValue != NaN && curValue != NaN) { var markerName = ("status_" + opts.status); if (curValue <= (maxValue * opts.barRatio) && curValue > maxValue * (opts.barRatio - .25)) { obj.set(markerName, opts.whenLow); } else { obj.set(markerName, !opts.whenLow); }; // this section tracks a characters HP value reaches and goes below 0, and marks them dead when they reach the death threshold }; if (obj.get("bar1_max") == "" ) { return } else { if (obj.get("bar3_value") == deadToken.unconscious + 1 ){ obj.set("status_redmarker", true); obj.set("tint_color", deadToken.dyingTint); obj.set("status_dead", false); } else if (obj.get("bar3_value") >= 1 ){ obj.set("tint_color", "transparent"); obj.set("status_dead", false); } else if (obj.get("bar3_value") <= deadToken.unconscious && obj.get("bar1_value") > deadToken.deathValue ){ obj.set("tint_color", deadToken.dyingTint); obj.set("status_redmarker", true); obj.set("status_dead", true); } else if (obj.get("bar3_value") <= deadToken.deathValue ){ obj.set("tint_color", deadToken.deadTint); obj.set("status_redmarker", false); obj.set("status_dead", true); }; } }); });