Skip to content

Instantly share code, notes, and snippets.

@poltergeisha
Created June 27, 2018 21:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save poltergeisha/50e4201f0afe96ad13690468ca381629 to your computer and use it in GitHub Desktop.
Save poltergeisha/50e4201f0afe96ad13690468ca381629 to your computer and use it in GitHub Desktop.
Limit HP Min Max
on('ready',function(){
"use strict";
var constrainBar1ToMax = function (obj) {
if (obj.get("subtype") != "token" || obj.get("isdrawing") == "true") return;
if (parseInt(obj.get("bar3_value")) <= 0 && parseInt(obj.get("bar3_max")) > 0) obj.set("bar3_value", 0);
if (parseInt(obj.get("bar3_value")) > parseInt(obj.get("bar3_max"))) obj.set("bar3_value", parseInt(obj.get("bar3_max")));
};
on("change:token", constrainBar1ToMax);
if('undefined' !== typeof TokenMod && TokenMod.ObserveTokenChange){
TokenMod.ObserveTokenChange(constrainBar1ToMax);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment