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

[Help] How to apply an initial version to my sheet

So I made the RuneQuest 6 sheet a while back.  It has gone through one major redesign already so i guess I'm on version 2.0 of the sheet right now.  With the new sheet worker scripts I'm preparing to introduce new features and various changes and would like to include a versioning system to migrate existing data as the sheet changes.  So the question: I suppose I would apply a version value the first time a sheet is opened with a sheet worker but how do I tell the difference between a new user who should be assigned the latest sheet version and an existing user who is opening the sheet for the first time since introducing the version system?  How have others done this?
1454644267
Lithl
Pro
Sheet Author
API Scripter
You could have the script manage a "version" attribute, and if the attribute doesn't exist, assume they've just upgraded from the version without a sheet worker.
1454646492
Chris D.
Pro
Sheet Author
API Scripter
Compendium Curator
Your API should also have your On ready event bind a handler for the on add:character event, and have that set your character sheet version number to the current version. That way you know the difference between a brand new character that was just created and one that is merely out of date. 
Can the add:character event be used within a sheet worker or would you need a full featured API script for that?  I'm trying to avoid the use of full on API scripts so those without Pro level subscription can still use the sheet effectively.
Brian said: You could have the script manage a "version" attribute, and if the attribute doesn't exist, assume they've just upgraded from the version without a sheet worker. Now that I have read your reply a few time I think I overlooked a key fact.  I can always start at version 1 and move through all migrations because new character have no current attributes.  The migrations will do nothing for them other than update the version attribute to match the current sheet version.  Outdated characters need all the migrations so they start at the bottom naturally, and active characters will already have a version attribute to compare against the sheet version.  I was worried about running migrations for new characters who didn't need it but I see now I don't need to worry about that. Thanks,