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
This post has been closed. You can still view previous posts, but you can't post any new replies.

API sheetworkers don't find default values for attributes displayed in multiple fields

1486739654
Lucian
Pro
API Scripter
It's not unusual for a character sheet to have multiple places that display the same value. One of these will be the primary place for it to be edited, while others will display it. The main editing field will have a default value defined, but the other displays will just reference the attribute. Take the following stub character sheet:   <input type="number" name="attr_baseattribute" value="8"> <span name="attr_baseattribute"></span> <input type="number" name="attr_depattribute" /> <input type="text" name="attr_triggerattribute"/>   <script type="text/worker">       console.info("Hello from sheetworker");           on("change:triggerattribute", function() {         console.info("Trigger attribute heard change");         getAttrs(['baseattribute'], function(vals) {            console.info('Base attribute value: ' + vals.baseattribute);            setAttrs({depattribute:vals.baseattribute});         });     });       </script> If I manually create a character and edit the triggerattribute field, I get the expected behaviour - the value of depattribute gets set to the default value of baseattribute (in this case 8), and the text 'Base attribute value: 8' is output to the log. If, however, I add the following API script: on('chat:message', function(msg) { 'use strict'; if (msg.content === '!test') {   const char = createObj('character', {name:'test'});     const attribute = createObj('attribute', { name:'triggerattribute', characterid:char.id});     attribute.setWithWorker({current:'foo'});   } }); and then trigger it from chat,  the dependent attribute gets set to the empty string, and the log output reads 'Base attribute value: '. If I remove the extra span from the character sheet html it works correctly, even under the API, so it looks like whatever is scanning the sheet for default values for the API sheetworkers is getting thrown by the presence of multiple fields for the same attribute (even though only one defines a default) when the equivalent code for the client handles this without problems. This is breaking some stuff for the 5e shaped sheet/script, so if it's not a hard problem it would be good to have a fix so we can take advantage of the API sheetworkers feature properly. Thanks!
1487631949
Gid
Roll20 Team
Thank you for posting Lucian, I've added this issue to our API tickets.
1487664323
Lucian
Pro
API Scripter
Hey Kristin, Riley's already on the case and there's a fix on dev: <a href="https://app.roll20.net/forum/permalink/4637640/" rel="nofollow">https://app.roll20.net/forum/permalink/4637640/</a> Cheers, Lucian
1488045780
Lucian
Pro
API Scripter
This is fixed on live now, this thread can be closed.
1488188615
Ziechael
Forum Champion
Sheet Author
API Scripter
Thanks for the update Lucian, thread closed.