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

Character Sheet Authors: A request from API Authors!

1488466694
The Aaron
Pro
API Scripter
There are a lot of times we could write scripts that would work better if we could know up front what sheet is being used by the characters.  There isn't a way inside Roll20 for the API to know that directly.  We can do some form of detection based on what attributes exist, but it's not always obvious what to look at or even if it's still relevant. I'm proposing that every sheet author that is willing should add a single attribute to characters that are using their sheet: Attribute Value character_sheet <sheet name> v<version number> The attribute should always have the same name.  This will allow you in your sheet workers to detect if the character comes from another sheet (say, switching from OGL to Shaped, or Traveller v1 to Traveller v2).  The format I suggest is having the name of the sheet, followed by the version number for the sheet.  The only important part is having a " v" in the middle so that splitting on the version number can be done easily and consistently.  If you don't have a version number for your sheet, just leave it off (and don't have a " v" at all).  Here are some examples: Attribute Value character_sheet Shaped v10.1.0 character_sheet 5e OGL Sheet v5.2 character_sheet Rifts v3 character_sheet Flashing Blades Thoughts? Suggestion?  I'll personally be using this to automate configuring scripts like GroupInitiative to work with a system based on the character sheet in use.
+1
1488467249

Edited 1488470360
Kryx
Pro
Sheet Author
API Scripter
Agreed and happy to help API scripts support sheets. I'll add this to Shaped v10.1.1 later tonight. EDIT: Added to Shaped 10.1.1.
1488467610
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
+1
1488468270

Edited 1488471763
Kirsty
Pro
Sheet Author
This is a brilliant idea! I'll add it to the Tales from the Loop sheet. EDIT: Added to TftL
1488469712
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
If we can get it added to at least the 5e sheets and the pathfinder sheet, as part of my next update to Easy Experience, I'll add this in to automatically determine what XP progression to use.
1488470437

Edited 1488472392
The Aaron
Pro
API Scripter
For simplicity, here is what I think might be the smallest possible Sheet Worker to add this to a sheet: <script type="text/worker">     var sheetName = ' Flashing Blades ';     var sheetVersion = ' 1.0.0 ';     on('sheet:opened', function(){         getAttrs(['character_sheet'],function(attrs){             let cs=_.rest((attrs.character_sheet||'').match(/(.*?)(?:\s+v(.*))?$/)),                 sheet_name=cs[0]||'',                 sheet_version=cs[1]||'';             // do something with sheet_name and sheet_version, if you might be converting             if(sheet_name !== sheetName || (sheetVersion && (sheet_version !== sheetVersion))){                 setAttrs({                     character_sheet: (sheetName||'NOT SET')+(sheetVersion?(' v'+sheetVersion):'')                 },{silent:true});             }         });     }); </script> All you have to change is the two bolded parts and append this to the end of an existing sheet and it will create and update the character_sheet attribute as needed.  You don't even need to have an explicit character_sheet input for this to work.  If you don't want a version number, just comment out the = part: var sheetName = 'Flashing Blades'; var sheetVersion ;// = '1.0.0';
1488472202

Edited 1488482754
The Aaron
Pro
API Scripter
Of course, you could also just add an attribute: <input type="hidden" style="display:none;" name="attr_character_sheet" value="Flashing Blades v1.0" disabled="true"> I think this would be overshadowed by any explicitly set attribute though, so if there are multiple competing character sheets in a given RPG (like DnD 5e has Shaped, Roll20 OGL, Community, etc), you'd probably want the sheet worker version.
1488664739

Edited 1488664752
chris b.
Pro
Sheet Author
API Scripter
Using the sheetworker to set the version would be preferrable, since when there is an upgrade the sheet attributes are not actually upgraded until the sheetworkers run and perform any migrations or updates necessary for that new version. Which brings me to another point, what about a standard name for an attribute that is watched by a sheetworker that updates it to the latest version? For instance, in the pathfinder sheet, API users can set the attribute "migrate1" to a sheet via setWithSheetworker and it will tell the sheet to upgrade itself to the latest version. Without a user having to open the sheet. We could settle on a different name, if a common one is desired.
1488665159
Kryx
Pro
Sheet Author
API Scripter
chris b. said: For instance, in the pathfinder sheet, API users can set the attribute "migrate1" to a sheet via setWithSheetworker and it will tell the sheet to upgrade itself to the latest version. Without a user having to open the sheet. We could settle on a different name, if a common one is desired. Lucian has a script to update all Shaped sheets to the latest so I expect this type of attribute is unnecessary, but I'm unsure how he did his implementation.
1488725692

Edited 1488725710
[Deleted]
Sheet Author
@The Aaron: I am definitely willing to add this to my sheet, but, I know nothing about sheet workers and I can guarantee even copying that and switching out details, I will mess something up. Would it be alright if I convo you in private about setting this up? I've been wanting to add a sheet worker script to my game for weight calculations anyways but never could wrap my head around how.
1488726943
The Aaron
Pro
API Scripter
Absolutely!  PM me anytime you like. My PM door is always open!  =D
1488940716
chris b.
Pro
Sheet Author
API Scripter
the new attribute will be available for the (complex) pathfinder sheet around tomorrow when the new one comes out. I called it "pathfinder_neceros" to match the name in github and differentiate it from the other PF sheets. So the first time it's available it will be: Pathinder_Necerosv1.17
1488957403
Kryx
Pro
Sheet Author
API Scripter
You need a space before the v
1488976554
chris b.
Pro
Sheet Author
API Scripter
augh! first bug found ;)
1488976623
The Aaron
Pro
API Scripter
=D  Now I need to do my part on the API side.  Thanks everyone!
1488980583
chris b.
Pro
Sheet Author
API Scripter
oh you know i forgot to put it in the html, I only added it in the JS, i suppose to be safe i'll put it in the html too, but does that matter?
1488981897
The Aaron
Pro
API Scripter
There really no need to put it there.
1494086059
Ada L.
Marketplace Creator
Sheet Author
API Scripter
I put in the character_sheet attribute for the Pathfinder (simple) sheet. Is the Character Sheet Detection sheet still going to be a thing? I haven't seen it in the API repository.
1494114644
The Aaron
Pro
API Scripter
Still planning on it being a thing. I haven't finished it yet though, been a bit swamped with work and things.