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

Dev servers not fully updating the campaign state when api changes something

1457624300
TheWhiteWolves
KS Backer
API Scripter
I have noticed a problem on the Dev servers that is requiring me to repeat the actions that my api script makes two time for the change to take effect, refer to&nbsp; <a href="https://app.roll20.net/forum/post/3077543/help-game-not-updating-with-scripts-changes" rel="nofollow">https://app.roll20.net/forum/post/3077543/help-game-not-updating-with-scripts-changes</a> where I first posted about the behaviour. Since the initial post I have run my script on the production servers and it only required a single call to function as expected so this looks to be only an issue on the dev servers. To give a bit of background, the script primarily makes changes to the playerspecificpages property of the&nbsp;Campaign object using Campaign().get("playerspecificpages"); and&nbsp;Campaign().set("playerspecificpages", playerPages); to move the player between maps and for one function makes changes to the&nbsp;playerpageid property of the Campaign &nbsp;object using Campaign().get("playerpageid"); and&nbsp;Campaign().set("playerpageid", bookmarkPage); to move all the players by moving the bookmark. The issue occurs when running the move function to move a player to another page, I have used many log() statements to find that on the first run the changes are made and when pulled using the get function again the changes are there, but the game and the player are not updated with the change, the move then has to be run a second time which causes the clients to be updated with the changes.
Two questions for you: 1) If you run it on another game on dev (not a copy of your current one but a new game) does it still exhibit the behavior? 2) The way that you're running it, is it likely that: Campaign().set("playerspecificpages", false); is being executed right before Campaign().set("playerspecificpages", playerPages); And if so...does removing the false one fix the issue at all? I don't think there's anything different between Dev and Main that would be causing this type of different behavior so just want to rule out those two things before I really start digging in. Thanks!
1457655669
TheWhiteWolves
KS Backer
API Scripter
Right, I've done abit of extensive testing, to start I'll answer your questions first. 1) I have move it to a seperate campaign that I created from scratch and the behavior is still present. 2) removing Campaign().set("playerspecificpages", false); causing the move action to fail every time. Now additional information I have found out from the testing, the strange behavior only starts to happen when a second player is moved to a separate map, i.e. you already have one player on another map and this is the second, third, forth etc that is moving.&nbsp;At this point the issue starts to appear causing each run to need two cycles. After further testing of theories I think I may have found a possible cause, it seems that whenever&nbsp;"playerspecificpages" is not set to false (i.e. already one player in it) it will take the changes and hold onto them but not update the clients with the new additions. The output below is from the debug statements I put into the script, Pre is set at just before the if statement to check the maps on line 231, Check Sender is just inside that if statement on line 233, Mid is inside the if statement to check is the player is already in playerPages on line 239,&nbsp;just after the delete statement, Post is just after it has added the entry to playerPages on line 237 and Final is at the end right after it sets playerPages and this one gets&nbsp;"playerspecificpages" to check if the change was made. Each of the " " after final is the separation between calls. (I have added comments to it to make it clearer) "********** Pre **********" {} "********** Check Sender **********" "-KCXs4Y3LKxdtxGt1BBr" {} "********** Post **********" {"-KCXs4Y3LKxdtxGt1BBr":"-KCXqX3CWMvI-7iPlBfB"} "********** Final **********" {"-KCXs4Y3LKxdtxGt1BBr":"-KCXqX3CWMvI-7iPlBfB"} " " // End of Run 1 of Player 1 - Worked "********** Pre **********" {"-KCXs4Y3LKxdtxGt1BBr":"-KCXqX3CWMvI-7iPlBfB"} "********** Check Sender **********" "-KCXq6KGeLC3YHldCbCb" {"-KCXs4Y3LKxdtxGt1BBr":"-KCXqX3CWMvI-7iPlBfB"} "********** Post **********" {"-KCXs4Y3LKxdtxGt1BBr":"-KCXqX3CWMvI-7iPlBfB","-KCXq6KGeLC3YHldCbCb":"-KCXqTtOh7F7p3ghZ83_"} "********** Final **********" {"-KCXs4Y3LKxdtxGt1BBr":"-KCXqX3CWMvI-7iPlBfB","-KCXq6KGeLC3YHldCbCb":"-KCXqTtOh7F7p3ghZ83_"} " " // End of Run 1 of Player 2 - Failed "********** Pre **********" {"-KCXs4Y3LKxdtxGt1BBr":"-KCXqX3CWMvI-7iPlBfB","-KCXq6KGeLC3YHldCbCb":"-KCXqTtOh7F7p3ghZ83_"} "********** Check Sender **********" "-KCXq6KGeLC3YHldCbCb" {"-KCXs4Y3LKxdtxGt1BBr":"-KCXqX3CWMvI-7iPlBfB","-KCXq6KGeLC3YHldCbCb":"-KCXqTtOh7F7p3ghZ83_"} "********** Mid **********" {"-KCXs4Y3LKxdtxGt1BBr":"-KCXqX3CWMvI-7iPlBfB"} "********** Post **********" {"-KCXs4Y3LKxdtxGt1BBr":"-KCXqX3CWMvI-7iPlBfB","-KCXq6KGeLC3YHldCbCb":"-KCXqTtOh7F7p3ghZ83_"} "********** Final **********" {"-KCXs4Y3LKxdtxGt1BBr":"-KCXqX3CWMvI-7iPlBfB","-KCXq6KGeLC3YHldCbCb":"-KCXqTtOh7F7p3ghZ83_"} " " // End of Run 2 of Player 2 - Worked As can be seen the first call where no players are currently separated from the bookmark works fine but the second call fails, but then succeeds on the second call, I then played around abit with different theories as to why this behaviour is happening and I think I may have come up with something. I added in an extra&nbsp;Campaign().set("playerspecificpages", false); at the end before it sets the changes&nbsp;"playerspecificpages" and this stopped the issue from happening. My theory is that updates to the&nbsp;"playerspecificpages" property are only being sent to the clients when it changes from false to an object or from an object to false and the reason that it would work ont he second call is because in the first run the player would be added to&nbsp;"playerspecificpages" thus triggering my piece of code that would remove them from playerPages, blank out the&nbsp;"playerspecificpages" by setting it to false and then reassembling playerPages with the players new location, this then meant that it would make an update when I set the new version of playerPages to the&nbsp;"playerspecificpages" property and by adding in the extra&nbsp;Campaign().set("playerspecificpages", false); I am forcing that reset of the property every time thus causing the update to happen now. I know this one is abit long but I hope it helps you with this issue.