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 Detection for the API

1488471998
The Aaron
Pro
API Scripter
Hey API Scripters! &nbsp;I made this post earlier today: &nbsp; <a href="https://app.roll20.net/forum/post/4714038/characte" rel="nofollow">https://app.roll20.net/forum/post/4714038/characte</a>... I'm asking Character Sheet Authors to introduce an attribute named character_sheet which the API can use to determine what character sheet is being used and take actions appropriate to it. &nbsp;Character Sheet Authors have been very receptive to this! In support of this, I'll be writing a script tonight which will provide detection of the Character Sheet, so we don't all have to do it. =D &nbsp;Here's what my proposed interface will look like: CharacterSheetDetection.currentSheet() Will give back an object with the sheet name and version &nbsp;{name: 'Shaped', version: '10.1.0' } CharacterSheetDetection.sheetChanged() Will be true if the sheet appears to be different than last time the API started up Caveat: This might be a bit strange as the attribute will likely get updated on sheet opened, unless it's just embedded via a hidden attribute. &nbsp;Basically, the script will develop a consensus based on the collection of attributes. CharacterSheetDetection.versionChanged() Will be true if the sheet version appears to have changed since the API last started (same caveat as above) CharacterSheetDetection.fullSheetData() Will return a structure with all the detected character_sheet values organized by unique sheet name, including counts occurring for both the name and the version: {'5e OGL Sheet': {count: 5, versions: {'1.0.1': 3, '1.0.0': 2}}, 'Shaped': {count: 23, versions: {'10.0.0': 20, '10.1.0': 3}}} Thoughts?
1488472854
Ada L.
Marketplace Creator
Sheet Author
API Scripter
I like this idea. Currently I'm working on a much more generic script for handling D&D5 and Pathfinder trap themes. This would work well with those to help look up attributes based on their known character sheet attribute names.
1488473095
The Aaron
Pro
API Scripter
Cool. &nbsp;Thinking about it, I might need to set this up to notify observers when detection has completed. &nbsp;I'll likely do the detection on('ready',...), so other scripts might have run before it has a chance to do the determination.
1488474201
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Are the above functions going to be asynchronous? If that's the case, perhaps they could just accept a callback parameter or return a Promise if no callback is given. Then the users of your script will get the value whenever its detection has completed sometime in the future.
1488474451
The Aaron
Pro
API Scripter
Ah, good point. &nbsp;I keep forgetting we can use Promises now. =D
1488550073
Kryx
Pro
Sheet Author
API Scripter
The Aaron said: Ah, good point. &nbsp;I keep forgetting we can use Promises now. =D So jealous. Sheet workers can't. :(
1488550749
The Aaron
Pro
API Scripter
Well, you CAN use them, they just break everything.. =D
1488560824
Lithl
Pro
Sheet Author
API Scripter
The Aaron said: Well, you CAN use them, they just break everything.. =D Only if you try to use a sheet worker API function in the asynchronous Promise context. So, if you try to do anything meaningful.
1488564235
Ada L.
Marketplace Creator
Sheet Author
API Scripter
Brian said: The Aaron said: Well, you CAN use them, they just break everything.. =D Only if you try to use a sheet worker API function in the asynchronous Promise context. So, if you try to do anything meaningful. This has caused me a lot of frustration while writing sheet workers... &gt;_&lt;
1488577333
Lithl
Pro
Sheet Author
API Scripter
Stephen L. said: Brian said: The Aaron said: Well, you CAN use them, they just break everything.. =D Only if you try to use a sheet worker API function in the asynchronous Promise context. So, if you try to do anything meaningful. This has caused me a lot of frustration while writing sheet workers... &gt;_&lt; Yeah, I tried writing my&nbsp; Sheetworker Autocalc using Promises at first, and it failed miserably. I managed to adapt the asynchronous waterfall Riley posted to get it to work properly.