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

ChatSetAttr only works in specific cases

Specifically, I can't get it to work with anything that isn't a raw input (number or text). I've tried using it to check checkboxes and to change the values of spin boxes, but to no avail. Anyone got ideas? This is the command: !setattr --name Laf Fut --spell_slots_l1_max|5 This is what's in the sheet html:     <div class="sheet-col-1-12"><input type="number" name="attr_spell_slots_l1_max" value="0"></div>
1754176765
Gauss
Forum Champion
Hi Charles d.,  Which character sheet are you using?
Gauss said: Hi Charles d.,&nbsp; Which character sheet are you using? Hi Gauss, I'm using a sheet that is designed for Basic Fantasy called "Basic Fantasy Expanded". <a href="https://github.com/Roll20/roll20-character-sheets/tree/master/Basic%20Fantasy%20RPG%20-%20Expanded" rel="nofollow">https://github.com/Roll20/roll20-character-sheets/tree/master/Basic%20Fantasy%20RPG%20-%20Expanded</a>
1754205828

Edited 1754205964
Gauss
Forum Champion
For future reference, the name of the sheet in the Roll20 dropdown menu for Character Sheets is "Basic Fantasy RPG". Could you please provide screenshots (with doodles to point out the boxes if possible) of the boxes etc you'd like ChatSetAttr to interact with? Specifically you mentioned checkboxes and "spinboxes". I need to know which ones and where those are on the sheet. Images work great for that.
Thanks. The spinbox (no idea if this is the right term, I'm not a native speaker) mentioned in my example is the one above. Below are the checkboxes I would like to address.
1754217956
Gauss
Forum Champion
What is the goal of using ChatSetAttr on each section?&nbsp;
1754232424
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
What command have you tried for setting the check boxes? The check values of the check boxes you circled are the roll template fields, I assume for those sections to be shown. E.g. info block's check value is: {{spellshowinfoblock=1}} So, you'd need to set it to this to check it, and set it to 0 to uncheck it.
Scott C. said: What command have you tried for setting the check boxes? The check values of the check boxes you circled are the roll template fields, I assume for those sections to be shown. E.g. info block's check value is: {{spellshowinfoblock=1}} So, you'd need to set it to this to check it, and set it to 0 to uncheck it. Thanks! This was indeed the only one I got to work. What would I need to put in to check the other boxes? When I tried to put in the check value of the other blocks, the API gave me some substring error.
Gauss said: What is the goal of using ChatSetAttr on each section?&nbsp; I want to check the checkboxes and I want to change the value from 0 to something else.
1754250607
Gauss
Forum Champion
Sorry, I am meaning in the broader sense. What is the goal for being able to do that via the API vs manually?&nbsp; Charles d. said: Thanks! This was indeed the only one I got to work. What would I need to put in to check the other boxes? When I tried to put in the check value of the other blocks, the API gave me some substring error. The problem with the other checkboxes is they contain more information in most cases, and in one...it is weird.&nbsp; So I am trying to find out what the overall goal here is. Perhaps there are other ways to accomplish it.
1754252625

Edited 1754252662
Gauss
Forum Champion
Here is what I have so far: * For spell slots what you want is the attribute @{spell_slots_l#|max} Where # is the level of the spell. !setattr --sel -- spell_slots_l#|max|value * For Info Block the following is what I have found to work:&nbsp; !setattr --sel --repeating_spellbooklvl# a _$# b _spellshowinfoblock|{{spellshowinfoblock=# c }} Where # a &nbsp;is the spell level and $# b &nbsp;is the number in the repeating list and # c &nbsp;is 1 or 0 (on or off). * For Saving Throw the attribute is:&nbsp; @{repeating_spellbooklvl1_$0_spellshowsavethrow} However, the output is more involved. For on we have:&nbsp; {{spellshowsavethrow=1}} {{spellsavestat=@{savestat}}} {{spellsavesuccess=@{savesuccess}}} For off we have: 0 The problem is, trying to apply that output attribute to ChatSetAttr isn't working. My guess is it is the sheet at fault, not ChatSetAttr. Scott would know more than I would though. Note: I tried removing the attributes and doing straight values in their place, but that didn't work either.&nbsp; Turning it off works fine though.&nbsp; * For Healing the attribute is:&nbsp; @{repeating_spellbooklvl1_$0_spellshowhealing} But like Saving Throw the output is more involved.&nbsp; For on we have:&nbsp;{{spellshowhealing=1}} {{spellhealing=[[@{spellhealamount} + @{healstatbonus}]]}} For off we have: 0 * For Damage the attribute is:&nbsp; @{repeating_spellbooklvl1_$0_spellshowdamage} But as before, it isn't simple.&nbsp; The on won't even display as an attribute, but it appears to be:&nbsp; &nbsp;{{spellshowdamage=1}} {{spelldamage=[[@{damage} + @{damagestatbonus} + @{damagemiscbonus}]]}} Off is 0 again, and will display as an attribute.&nbsp; Finally, for Effects the attribute is:&nbsp; @{repeating_spellbooklvl1_$0_spellshoweffects} On is:&nbsp; {{spellshoweffects=1}} {{spelleffect=@{spelleffect}} Off is: 0 As before, on won't work for ChatSetAttr, off will.&nbsp; There you have it, perhaps Scott C. can figure out a way to access JUST the {{stuff=1}} section without the rest in the sheet, but I am unable to find an attribute for that section alone using Inspector.
1754262837

Edited 1754262887
Gauss said: Here is what I have so far: * For spell slots what you want is the attribute @{spell_slots_l#|max} Where # is the level of the spell. !setattr --sel -- spell_slots_l#|max|value * For Info Block the following is what I have found to work:&nbsp; !setattr --sel --repeating_spellbooklvl# a _$# b _spellshowinfoblock|{{spellshowinfoblock=# c }} Where # a &nbsp;is the spell level and $# b &nbsp;is the number in the repeating list and # c &nbsp;is 1 or 0 (on or off). * For Saving Throw the attribute is:&nbsp; @{repeating_spellbooklvl1_$0_spellshowsavethrow} However, the output is more involved. For on we have:&nbsp; {{spellshowsavethrow=1}} {{spellsavestat=@{savestat}}} {{spellsavesuccess=@{savesuccess}}} For off we have: 0 The problem is, trying to apply that output attribute to ChatSetAttr isn't working. My guess is it is the sheet at fault, not ChatSetAttr. Scott would know more than I would though. Note: I tried removing the attributes and doing straight values in their place, but that didn't work either.&nbsp; Turning it off works fine though.&nbsp; * For Healing the attribute is:&nbsp; @{repeating_spellbooklvl1_$0_spellshowhealing} But like Saving Throw the output is more involved.&nbsp; For on we have:&nbsp;{{spellshowhealing=1}} {{spellhealing=[[@{spellhealamount} + @{healstatbonus}]]}} For off we have: 0 * For Damage the attribute is:&nbsp; @{repeating_spellbooklvl1_$0_spellshowdamage} But as before, it isn't simple.&nbsp; The on won't even display as an attribute, but it appears to be:&nbsp; &nbsp;{{spellshowdamage=1}} {{spelldamage=[[@{damage} + @{damagestatbonus} + @{damagemiscbonus}]]}} Off is 0 again, and will display as an attribute.&nbsp; Finally, for Effects the attribute is:&nbsp; @{repeating_spellbooklvl1_$0_spellshoweffects} On is:&nbsp; {{spellshoweffects=1}} {{spelleffect=@{spelleffect}} Off is: 0 As before, on won't work for ChatSetAttr, off will.&nbsp; There you have it, perhaps Scott C. can figure out a way to access JUST the {{stuff=1}} section without the rest in the sheet, but I am unable to find an attribute for that section alone using Inspector. Thanks for going through all this. I will go through the spellslots tomorrow to see if it works. For the boxes, in the end, if there's no solution than it is like it is. But maybe Scott C. will pull some wizardry :-)
1754269109
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Ah, those other have attribute calls in them, you'll need to html escape the @ so that the chat parser doesn't try to parse them as attributes. May need to do more than one level of escaping.
Scott C. said: Ah, those other have attribute calls in them, you'll need to html escape the @ so that the chat parser doesn't try to parse them as attributes. May need to do more than one level of escaping. Thank you for the suggestion! Replacing @ with &amp;commat; I get the following output: Setting repeating_spellbooklvl1_$0_spellshoweffects to {{spellshoweffects=1}} {{spelleffect=@{spelleffect}} for character #name# It addresses the right attr, since it unchecks the box if I do it, but from the output I'd wager I put in the correct thing. Could you elaborate what multiple levels of escaping would mean in that context?
Gauss said: Here is what I have so far: * For spell slots what you want is the attribute @{spell_slots_l#|max} Where # is the level of the spell. !setattr --sel -- spell_slots_l#|max|value This worked, thank you very much! I also saw that I overlooked one question: why do all that. The answer is that I created an Excel sheet (yeah, I know, but I can work well with Excel and VBA because of my&nbsp;work) where you can generate characters and get lists of all their respective class abilities, spells, etc. at their current level (see attached screenshot). This is very neat, as it saves time rummaging through the distributed set of all the additional classes we created over the years and is easier to copy into an actual character sheet etc. The next step I wanted to do is to create an export string that would then automatically fill out your sheet. This is working fine except for the cases I mentioned. It is really a minor thing: I want to add the respective spells of the class at the specific level to the spellbook (which works fine) and fill out their information (also works). I would then also like to "pre-configure" the spells so that the right boxes are checked and clicking will display the needed information (i.e. damage for Fireball, but not for Cure Light Wounds, where it would show healing). Of course, you could simply check the boxes the first time you're casting the spell, but still - if it's possible I'd like to implement the more comfortable solution.