Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Event firing when you close the turnorder

1590443523

Edited 1590443556
I am trying to come up with a way to fire up an event when you close the turnorder. I have tried the following: on("change:campaign:initiativepage", function(obj){     DoSomething(obj);    }); but it fires when the turnorder open or closes.  Is there a way that would call the DoSomething function only when you close the turnorder ?
1590461124

Edited 1590462541
Victor B.
Pro
Sheet Author
API Scripter
    handleTurnorderChange = function (obj, prev) {         if (debug) {             log("Handle Turnorder Change")         }                  if(obj.get('turnorder') === prev.turnorder) return;         let turnorder = (obj.get('turnorder') === "") ? [] : JSON.parse(obj.get('turnorder'));         let prevTurnorder = (prev.turnorder === "") ? [] : JSON.parse(prev.turnorder);         if(obj.get('turnorder') === "[]"){             stopCombat();             return;         }         if(turnorder.length && prevTurnorder.length && turnorder[0].id !== prevTurnorder[0].id){             doTurnorderChange();         }     },