Here's a very basic script that will show the effects when bar_1's value changes. You can change which bar you use to check by changing the hpBarId value at the top of the script (1, 2 or 3). I tested this on my "script test game" where it was the only script running and it worked as expected... on my own actual game for some reason spawnFx functionality has stopped working (even if I disable all the other scripts... so no idea what's going on there). But here's the script, hope it helps (EDIT: Added David M's check, to make sure it just runs on the current page) : var HitPointsChangeEffect = HitPointsChangeEffect || (function() {
'use strict';
const version = '1.0.0',
hpBarId = 1,
checkInstall = function() {
log(`-=> HitPointsChangeEffect v${version} <=-`);
},
handleToken = function(obj, prev) {
const currentHP = obj.get(`bar${hpBarId}_value`);
const prevHP = prev[`bar${hpBarId}_value`];
const playerPage = Campaign().get('playerpageid');
if (obj.get('pageid') === playerPage) {
if (currentHP < prevHP) {
log('took damage');
spawnFx(obj.get('left'), obj.get('top'), 'glow-blood');
} else if (currentHP > prevHP) {
log('healed');
spawnFx(obj.get("left"), obj.get("top"), "burn-acid");
}
}
},
registerEventHandlers = function() {
on(`change:graphic:bar${hpBarId}_value`, handleToken);
};
return {
CheckInstall: checkInstall,
RegisterEventHandlers: registerEventHandlers
};
})();
on('ready',function() {
'use strict';
HitPointsChangeEffect.CheckInstall();
HitPointsChangeEffect.RegisterEventHandlers();
});