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

state data being reset randomly?

1413657840

Edited 1413658116
So I wrote a script to help manage scheduling in a campaign with over 100 players, Players can do "!signup Sunday" to roll using Math.random(). This is stored in the two dimensional array state.Scheduling.sundayPlayers using push() along with the player ID as long as the player ID isn't already there. It's then sorted using sort(). If a text object has been designated and is found using "!setupsignup Sunday", it will format and output the rolls to that text object. The GM can clear the data by using !clearsignup Sunday and see raw data with !rawsignup Sunday. This script uses The Aaron's script isGM. Pretty simple stuff. However, it seems every night the state object gets cleared. state.Scheduling's members report as empty. This should only happen when explicitely commanded by the GM or if state.Scheduling is missing. My question is whether this is something I'm overlooking, a limitation of the API, or anything else. Disclaimer: This is my first script using the API and it isn't wrote optimally at all. <a href="http://pastebin.com/SGVu4C8W" rel="nofollow">http://pastebin.com/SGVu4C8W</a>
Rather than rely on the state data, you should just create a hidden journal or handout and use that to store the information. This would also make it easier for you to glance at the list if you made it in a readable and parsable format.
1413664507
Lithl
Pro
Sheet Author
API Scripter
Zamp is using state for exactly the sort of thing that it's meant to be used. Suggesting ugly hacks instead isn't very helpful. As for the code, I can't see any reason why state would be getting cleared as you describe. Perhaps you could share some of the API log from when this is happening?
I wouldn't rely on that variable when api servers get spun up and down all the time. I'd rather have the data somewhere more "solid" and viewable outside of the API.
The only way to see the log is to have it open when the issue happens, but I can't seem to recreate whatever causes this. If the API servers aren't reliable like HoneyBadger says, I may just have to use that hacky solution .. although I rather not.
1413667440

Edited 1413667479
The Aaron
Roll20 Production Team
API Scripter
I have never had an issue with the state being cleared that wasn't a programmatic error. Are you running any scripts beside the isGM one and yours? Also, is the isGM state being preserved and just your array is being cleared?
I use plenty of state objects in my campaign and the data remains intact from week to week. I have on occasion managed to 'corrupt' the state object and it was automatically reset but that was only through programming error.
1413684926
Lithl
Pro
Sheet Author
API Scripter
Zamp said: The only way to see the log is to have it open when the issue happens, but I can't seem to recreate whatever causes this. If the API servers aren't reliable like HoneyBadger says, I may just have to use that hacky solution .. although I rather not. Your script is sending messages to the log when it's taking various actions, such as being set up. Is the state object getting blanked entirely? The state object is periodically saved (every ~5s, if I recall correctly). As far as I'm aware, the API server getting restarted should not cause any issues, and I don't know where HB is coming from.
1413685371
The Aaron
Roll20 Production Team
API Scripter
Concur. Riley has said that it is persisted to the DB about every 5 seconds, when talking about why storying those big "database" scripts in the state is a bad idea. The DB servers are not the API servers, the API servers crashing would not result in destroying the state object in the DB. That would make a pretty terrible DB. It would be like mysql dropping tables if your PHP threw an exception.
I'm only running this script and isGM. As far as I can tell, isGM is being preserved. scheduling is get completely blanked, yet the only command that would do that in my script is behind an if statement that gets fired when scheduling doesn't exist.
I just don't like relying on something so easy to screw up.
1413754709
The Aaron
Roll20 Production Team
API Scripter
Ok.. I must now partially rescend my previous response. Anyone ever see this message in the API log? "There was an error restoring your API state. It was corrupt. Resetting to a blank state." Was trying to track down a bizarre issue in Bryce's game and got that error. Everything is fine now, the error is gone. weird.