Hey everyone,
We've just pushed a new update out the API for the Dev Server which provides the following new features:
setDefaultTokenForCharacter(characterObj, graphicObj)
This is a new function which allows you to use the API to set the default token for a Character. To use it, just pass in a Character object (that you can get with e.g. findObjs() or getObj()) and a Graphic object. It will handle doing all the necessary work to set up the Character's default token to a snapshot of the Graphic object. Note that default tokens are snapshots, not links, so if you change something about the Graphic object and you want to update the default token, you'll need to call this again. Also note that the Graphic object will not be automatically linked to the Character via its "represents" field, so be sure to set that in advance.
Fixes for repeating_$n variables
Behavior when using repeating_$n variables (for example, repeating_spells_$1_name to get the name of the spell in the second row of a repeating section) should now match the rest of Roll20's behavior. This change applies both to sendChat() calls (which had support for these previously but could possibly not match the correct order), and we have also added support for them when using getAttrByName(). In addition, getAttrByName() is now case-insensitive, as with the rest of variable usage in Roll20.
Fix for noarchive: true
There was a behavior previously where if you called sendChat() with the noarchive:true flag set, it could result in multiple "chat:message" events being called for the same message. This should now be fixed.
In addition to these changes, internally we have a prototype of the code which can run the Sheet Worker scripts from Character Sheets on the API Server. However, I'm thinking it might be best to not turn this on by default for all sheets and scripts, since it's possible existing scripts may not anticipate this new interaction and it could cause issues. So I wanted to get the community's input on what the best way might be to handle that. Right now I'm leaning toward requiring you to set a flag on the API Scripts page that says "Execute sheet worker scripts in the API" or something of that nature. At least until we've thoroughly tested the possible interactions and given script authors time to make sure it won't interfere with their existing scripts. Thoughts?