It is possible to automate that, and more (like stop the current from going above max), but it's tricky because there might be changes you want to apply manually and its easy to not account for that and end up with attributes that are out of sync. For example, here's a worker that will change the current hp whenever the max changes (up or down), and will not raise the currenthp above the current max (so if already above the max, it will be reset): on("change:hp_max", function (event) { getAttrs(["hp"], function (values) { const hp = +values.hp || 0; const oldmax = +event.previousValue || 0; const newmax = +event.newValue || 0; if (oldmax && newmax ) { const change = newmax - oldmax;
const newhp = Math.min(hp + change, newmax); setAttrs({ hp: newhp }); } }); }); The if statement in the middle is to ensure it runs only when there's a valid oldmax and newmax value. But calculations like these are a little tricky, and depending on the way you run the game (are their temporary buffs, conditions that alter stats, etc)., we may need to think more carefully about the logic.