I'm looking for a solution to the following problem: My group plays 5e D&D with a variant hp rule. You have hit points equal to your level plus your Constitution modifier and if you take damage in excess of this, your hit points reset (damage carries over) and you take a level of exhaustion. Functionally, this means that you have max hp = 6 * (LEVEL + CON) since there are five levels of exhaustion. What I'd like is an API script that checks when a token is modified, and appropriately increments the skull token, and corrects the hit points as appropriate. I'm familiar with programming, but Javascript/web development is entirely new to me. I imagine that I would need something along the lines of: on("change:token", function(obj){ // if the target doesn't have their max hp keyed to their bar1 // then don't run this script if(obj.get("bar1_max") === "") return; // if the target's hp falls to zero or below, add a wound counter // and increase their hp by maximum if(obj.get("bar1_value") <= 0) { obj.set("status_skull",obj.get("status_skull")+1); obj.set("bar1_value",obj.get("bar1_value") + obj.get("bar1_max")); } }) or alternatively (using total effective hp) on("change:token", function(obj){ if(obj.get("bar1_max") === "") return; var nWounds = 6 - ceil(6 * obj.get("bar1_value") / obj.get("bar1_max")); obj.set("status_skull",num.toString(nWounds)); }) I would love to just implement Token-Mod and be done with it, but I can't figure out how to do it in a macro (which obviously doesn't run itself). I don't know how to make Token-Mod reference token properties, e.g. !token-mod --set statusmarkers|skull:+1 --set bar1_value|@{target|bar1_value}+@{target|bar1_max} isn't working for me. I also am not clear on how to implement Token-Mod inside of a .js file. I know I'm butchering syntax in at least several places, so maybe this is an easy fix? Any help would be appreciated.