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

Looking for tips importing character sheets via JSON [Hero6e]

1615580952
Ernest P.
Pro
API Scripter
Hi. New to the forums, I decided to try taking a stab at importing character sheets into an existing character sheet and I am hitting some challenges I'd like to see if someone can help with. Basics: 1. Character sheet is called Hero System 6e. 2. I have a Pro subscription. 3. I have have experience coding, although my js is a bit rusty and I am okay with JSON. 4. I have a character sheet template available in JSON. 5. I have gotten as far as writing a script, parsing the JSON (including some cleansing) and can log values from it. That basically leaves me with setting the values on the target sheet, which is where I am at currently. I have tried several things but so far I am not seeing the results on the character sheet. Here is a snippet of current code:       var hdJSON = JSON.parse(gmnotes);       log(hdJSON.str);       createObj('attribute', {name : "attr_str_base", current: hdJSON.str.value, characterid: character.id}); Code produces no errors, outputs the correct STR ("16") but does not change the character sheet value. Thoughts? - E
1615584056

Edited 1615584079
Kavini
Pro
Marketplace Creator
Sheet Author
Compendium Curator
When retrieving values from a javascript object, you don't need to add 'value'. i.e. createObj('attribute', {name : "attr_str_base", current: hdJSON.str , characterid: character.id});
1615586879
Ernest P.
Pro
API Scripter
I originally had it that way, changed because that JSON node has other attributes, but it works the same either way. Prints "16" just fine but does not change the character sheet value. - E
1615667685
Kavini
Pro
Marketplace Creator
Sheet Author
Compendium Curator
Could you post the whole script? It's hard to identify issues without seeing how you're resolving the character id, etc.
1616360458
Ernest P.
Pro
API Scripter
Thanks, @Nic B. I figured out eventually that the sheet has it's own edit button that toggles the ability to change attributes and does so through a different set of fields. On to the next challenge now, working through some JSON errors. - E