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 and repeating sections on character sheets

I am not sure if this is exactly a bug report... but the API seems to have very limited ability to work with the new repeating sections.  Looking at a simple attribute created as a repeating object: {"name":"repeating_attack_-K9rWJzSqmobyHSFL1de_name", "current":"Quarterstaff","max":"","_id":"-K9rWKdIq0rQVFMWT2Wd", "_type":"attribute", "_characterid":"-K9wHc-GqSXatsmDPf9t"} It seems to me that in order to create an attribute (or most objects) you must specify the _characterid and the name, but there seems to be no way to create a valid name without know the ID, but there seems to be no way to create the ID. Using the "$#" (i.e. repeating_attack_$0_name) syntax kind of works... but I will be honest, it's very strange. In my test I simply added a new attribute name, which is only one attribute of many in the repeating section. I expected that it would add it to the bottom of the repeating section and the remaining attributes would be blank, however this was not the case. It added to the "top" of the section and the remaining attributes that I didn't fill in were identical to the row below it. There are additional problems with creating resources with the API using the "$#" syntax, any of the rows I created while testing this syntax can't be deleted from the sheet. If we can't properly create rows via the API, it seriously limits what is possible as far as interaction with the sheets. Feels like a very serious limitation right now, again unless I am missing something or simply doing something completely wrong. Console.log: DELETE REPEATING ROW: repeating_attack_$4 ERROR: Invalid attempt to delete repeating row: repeating_attack_$4_ CLICKED DELETE REPEATING ROW: repeating_attack_$5 ERROR: Invalid attempt to delete repeating row: repeating_attack_$5_ CLICKED DELETE REPEATING ROW: repeating_attack_$7 ERROR: Invalid attempt to delete repeating row: repeating_attack_$7_ CLICKED Below is a sample script that I was testing with while using the newest Shaped Sheet (version currently in development), I was simply manually changing line 34 of the script to create attributes with the "$#" syntax by running the !ca command. You are welcome to join the testing campaign where this script is located as well. var createAbility = createAbility || (function() { 'use strict'; var version = '0', checkInstall = function() { log('version'); }, handleInput = function(msg) { var args,token,character; if (msg.type !== "api") { return; } args = msg.content.split(/\s+/); switch(args[0]) { case '!ca': log('hooray!'); if (!(msg.selected && msg.selected.length)) { sendChat("TokenAction", "/w " + msg.who + " No token selected"); return; } token = getObj('graphic', msg.selected[0]._id); if (!token.get('represents')) { sendChat("TokenAction", "/w " + msg.who + " Token does not represent a character"); return; } character = getObj('character', token.get('represents')); createObj("attribute", {name: 'repeating_attack_$7_name', current: 'testingXYZ', _characterid: character.id}); break; } }, registerEventHandlers = function() { on('chat:message', handleInput); }; return { CheckInstall: checkInstall, RegisterEventHandlers: registerEventHandlers }; }()); on('ready',function() { 'use strict'; createAbility.CheckInstall(); createAbility.RegisterEventHandlers(); });
Aaron provided a solution to this problem that seems to be working well in my limited testing. &nbsp;Details are here: <a href="https://app.roll20.net/forum/post/3025111/api-and-" rel="nofollow">https://app.roll20.net/forum/post/3025111/api-and-</a>... As I mentioned though in that thread, this is probably a good item to document as more and more sheet take advantage of the repeating section, I suspect that this may come up again.
1456779138
Silvyre
Forum Champion
I'll mark this (tentatively) as resolved, then. Please do create another bug report if it does come up again, though. Thanks!