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

Turnorder triggering change event twice

Hi all, I couldn't find where this was being mentioned anywhere else. I have been using a script for a while to manage the count on a token's status counters when the token's turn starts. This is done with the event "change:campaign:turnorder". Recently, I can't say when exactly when, I noticed that it was deducting the count on two tokens each turn at the start and end of a turn. Basically, I found that the event is triggering twice when the turn order advances. After figuring this out, I built a state.turnorder and an if/else statement to detect when the first event called (the token finishing it's turn is moved to the bottom of the list) and when the second event is called (when the next token is moved to the top of the list) to figure out when to trigger my API. But here's the kicker: in my copied instance where I develop this is happening 100% of the time. In my live game the douple trigger is NOT happening every time and so my if/else causes a random staggering to the status count deduction. Has anyone else encountered this? I've been all over the API documentation and cannot find this mentioned anywhere. I have another API making use of the event "change:campaign:turnorder" but it isn't having the problem since I keep track of the state.lastturn for that API to announce when it's a new token's turn so that way I ignore the first event. It looks like I might need to be doing this for every turnorder API.
1441044212
The Aaron
Pro
API Scripter
Ken L. has brought up the issues with this event before.  I've similarly run into bizarre cases, but not explored them too much.  Have you tried your testing with all other scripts disabled?
I just checked with all but a few disabled and still the same results. I am using this to check the event: on("change:campaign:turnorder", function(obj) {     log("start");     log(state.turnorder);     var turn_order = JSON.parse(Campaign().get("turnorder"));     var turn = turn_order.shift();     if(state.turnorder === 2) {         log("turned");         log(getObj("graphic", turn.id));         state.turnorder = 1;     } else {         log("else");         log(getObj("graphic", turn.id));         state.turnorder = 2;     } }); Every time the turn order is advanced one token i get the "else" and then the "turned".
1441111215
The Aaron
Pro
API Scripter
How many items in the turn order?
From my testing it doesn't seem to matter. I can have 2 or 10 and the event triggers twice in one game and sometimes twice in another. It never has fired more than twice per advance.