Hello! I'm hoping someone can provide help with a new issue I've run into. I've recently converted my long term D&D campaign from the old engine to Jumpgate, and haven't run into any problems until now. My group and I have been in a long roleplay period without any combat encounters, and until last weekend hadn't run a combat encounter. While fighting, token markers kept disappearing from tokens whenever a tokens bars was modified. It took me a bit to figure out where the issue came from, and through a lot of script disabling, I finally found the culprit; a script written years ago by The Aaron himself. The script is a favourite among my players, so I'm hoping someone can tell me what goes wrong with it, and, if possible, supply a solution. The script itself: /* global TokenMod */
on('ready',()=>{
// CONFIGURE
const bar = 3;
const bloodied = "bloodied::5488131";
const dead = "dead";
// no edit below here //
const unpackSM = (stats) => stats.split(/,/).reduce((m,v) => {
let p = v.split(/@/);
p[0]=p[0].toLowerCase();
let n = parseInt(p[1] || '0', 10);
if(p[0].length) {
m[p[0]] = Math.max(n, m[p[0]] || 0);
}
return m;
},{});
const packSM = (o) => Object.keys(o)
.map(k => ('dead' === k || true === o[k] || o[k]<1 || o[k]>9) ? k : `${k}@${parseInt(o[k])}` ).join(',');
const handleBarChange = (obj) => {
const bv = parseFloat(obj.get(`bar${bar}_value`));
const bm = parseFloat(obj.get(`bar${bar}_max`));
if(Number.isNaN(bm)){
return;
}
let sm = unpackSM(obj.get('statusmarkers'));
if(bv <= (bm / 2) && bv > 0) {
sm[bloodied] = true;
}
else{
delete sm[bloodied];
}
if(bv <= 0) {
sm[dead] = true;
}
else {
delete sm[dead];
}
obj.set({
statusmarkers: packSM(sm)
});
};
on(`change:graphic:bar${bar}_value`, handleBarChange);
if('undefined' !== typeof TokenMod && TokenMod.ObserveTokenChange){
TokenMod.ObserveTokenChange(handleBarChange);
}
}); The bar it checks as well as the marker it places for bloodied have been changed, but the script is otherwise original.