As the title says, I'm trying to use a custom status marker with the above scripts. I found this old thread which got me going in what I think is the right direction, but the thread ended before it got past the problem with parsing the "::" in the icon ID, which is where I think my problem lies. I got the ID of the custom status marker that I want to use ( unconcious [ unconcious::3443139 ] ) from TokenMod: I then added that to the list of status markers in the ApplyDamage script. Now I wanted to edit the HPBarTracker script to do two things: To add the "unconcious" status marker to a token when its bar1 value equals zero (0), add the "dead" status marker (Big Red X) if the value went to less than zero ( <0 ), and remove the "dead" status marker if the bar1 went to >= 0. on('ready', () => {
const HPBarNum = 1;
const bar = `bar${HPBarNum}_value`;
const max = `bar${HPBarNum}_max`;
const constrainHPBarToMax = (obj) => {
const hpMax = parseInt(obj.get(max),10);
if(!isNaN(hpMax) && 'token' === obj.get('subtype') && !obj.get('isdrawing') ){
let hp = parseInt(obj.get(bar),10);
let changes = {};
if(hp > hpMax) {
hp = hpMax;
changes[bar] = hp;
changes.status_dead = false;
} else if(hp == 0) {
hp=0;
changes[bar] = hp;
changes.status_dead = false;
changes.status_unconcious::3443139 = true;
} else if(hp < 0) {
hp=-1;
changes[bar] = hp;
changes.status_dead = true;
} else {
changes.status_dead = false;
}
obj.set(changes);
}
};
on("change:token", constrainHPBarToMax);
if('undefined' !== typeof TokenMod && TokenMod.ObserveTokenChange){
TokenMod.ObserveTokenChange(constrainHPBarToMax);
}
if('undefined' !== typeof ApplyDamage && ApplyDamage.registerObserver){
ApplyDamage.registerObserver('change',constrainHPBarToMax);
}
}); This is the error I get when I restart the sandbox: If I change the name of the status marker in HPBarTracker to just "unconcious" (or anything else) the script works fine - it ignores the bar1 value if it's >= 0 and adds the "dead" marker if the bar1 value is < 0. I'm not skilled in coding but I can often edit a (simple) existing script to do what I want. Where am I going wrong here?