The Aaron said: Here ya go: /* global TokenMod */
on('ready',()=>{
const BAR = 1;
const BIAS = 1;
/////////////////////////////////////////////
const BarProp = `bar${BAR}_value`;
const handleGraphicChange = (obj,prev) => {
if(parseInt(prev[BarProp]) !== parseInt(obj.get(BarProp))){
let sides = decodeURIComponent(obj.get('sides')).split(/\|/);
let maxSides = sides.length||0;
if(maxSides){
let currSide = parseInt(obj.get('currentSide'))||0;
let newSide = Math.max(BIAS,Math.min(maxSides,obj.get(`bar${BAR}_value`)||BIAS));
if((currSide + BIAS) != newSide){
obj.set({
currentSide: newSide,
imgsrc: sides[newSide-BIAS]
});
}
}
}
};
on('change:graphic', handleGraphicChange);
if('undefined' !== typeof TokenMod && TokenMod.ObserveTokenChange){
TokenMod.ObserveTokenChange(handleGraphicChange);
}
});
Wow, Thank you very much!! However I have this error in the sand box, "ERROR: Please use the 'thumb' size for imgsrc properties." how may I fix this? Sorry for bothering you ;D