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 .
×

Need help with ChatSetAttr and repeating attributes

1595363814

Edited 1595363995
Mech
Pro
Sheet Author
Im using a custom sheet, and one button that is part of a repeating section that rolls a dice has to increase a value. For this I am using: !modbattr --name @{charactername} --qp|{{qp=QP changes by [[1]]}}}}!!! This works great. The problem is this is increasing a fixed attribute, now I need another increase on a repeating value within the original repeated section. In the image we see, when I press the CP button (blue), the Uses input (red) should increase. This whole line in the image is the repeating section. Each one is individual. I tried some ways to make it work, like using  repeating_prefix_$0_attribute, but I dont know the ID or the index before assigning it. Ive also tried many different versions of: !modbattr --name @{charactername} --cp|{{cp=CP changes by [[-1]]}} --attr_TraitUses|{{attr_TraitUses=Uses changes by [[1]]}}!!! Nothing has worked. Is there something I can do? Am I missing something?
1595386874
GiGs
Pro
Sheet Author
API Scripter
You're asking us to guess what attribute names you should use. You need to post the code for the fieldset, at least its name and any attributes relevant to your question. That said, I do see a big problem: You shouldnt have the attr_ part in the script command. Try !modbattr --name @{charactername} --cp|{{cp=CP changes by [[-1]]}} --TraitUses|{{TraitUses=Uses changes by [[1]]}}!!! The attr_ part is not actually part of the attribute name. It is a flag that signals to roll20, "this is an attribute, handle it accordngly." There are also names with roll_  and act_  before them, and roll20 handles each one differently. I havent used the rolltemplate supporting code in chatsetattr yet, so cant be sure of the syntax. I would recommend getting the actual numbers working first, then try to get that working: !modbattr --name @{charactername} --cp|-1 --TraitUses|1 Finally, since it's in a repeating section, you'll need to use repeating section syntax. You can use the $0 id format for row number. !modbattr --name @{charactername} --cp|-1 --repeating_whatever_$0_TraitUses|1 Change whatever to whatever it should be. The problem of course is you need to set the $0 manually. Since you';re using a custom sheet, you can fix this with a sheet worker to always use the full proper row id, so that it'll always work. But I cant offer a code solution to do that without seeing the complete repeating section code. In short though: you'd have a hidden attribute to contain the row id, and whenever a row is created, a change event would populate that with the correct rowid using the sheet worker function getSectionIds. Then your code above with have an attribute reference in place of the $0 pointing to that hidden attribute.  
1595435430
timmaugh
Roll20 Production Team
API Scripter
I have a script (in dev) that -- in part -- interrogates the character sheet to help you construct the right kind of command line call. Like I said, it's in development, so not everything in the script works, but the xray interrogation works, so you can check it out. You can find it here . Copy the code and drop it into your game, naming the script "InsertArg". Once you're done with that, you can use the xray feature of the script. Enter the following command in the chat: !xray --[character name] ...where [character name] is the character you want to xray. Alternatively, you could provide a character id or token id and the script will work. The script will return all repeating sections of the character with api buttons to let you drill down on the elements within that section. (you might want to expand your chat, especially for the next step.) Clicking on one of those buttons will xray the corresponding repeating section, so you can see the interior elements. When you click a button, it will ask you what which repeating thing you want to xray (at what position). The positional numbers start at 0. (I think the positional value the script references is the appearance on the sheet, not the order the components were added, but I could be wrong.) Here is the result of clicking the "powers" xray button and picking slot 10 from the character I began xray-ing: I know that's a bit difficult to read, but you can see that it shows you all of the sub attributes associated with that repeating attribute. Where it detects that an attribute is executable, you will see 3 buttons. XRAY - will build an output of api buttons from this section using that item as the action to execute (think: cross-tab output); it will ask you what sibling attribute to use as the name on each button (and it will guess if it detects the characters 'name' in the sibling attribute name). VIEW - will show you the text of that attribute without executing it EXEC - will execute the attribute as if you had run it, in game Hopefully this helps you interrogate the sheet to find the pieces you need to push around and plug into your macro... post back if you have questions. (Just to say it again, this is not the finished version, so new versions will be coming)
1595445668
Mech
Pro
Sheet Author
GiGs said: You're asking us to guess what attribute names you should use. You need to post the code for the fieldset, at least its name and any attributes relevant to your question. That said, I do see a big problem: You shouldnt have the attr_ part in the script command. Try !modbattr --name @{charactername} --cp|{{cp=CP changes by [[-1]]}} --TraitUses|{{TraitUses=Uses changes by [[1]]}}!!! The attr_ part is not actually part of the attribute name. It is a flag that signals to roll20, "this is an attribute, handle it accordngly." There are also names with roll_  and act_  before them, and roll20 handles each one differently. I havent used the rolltemplate supporting code in chatsetattr yet, so cant be sure of the syntax. I would recommend getting the actual numbers working first, then try to get that working: !modbattr --name @{charactername} --cp|-1 --TraitUses|1 Finally, since it's in a repeating section, you'll need to use repeating section syntax. You can use the $0 id format for row number. !modbattr --name @{charactername} --cp|-1 --repeating_whatever_$0_TraitUses|1 Change whatever to whatever it should be. The problem of course is you need to set the $0 manually. Since you';re using a custom sheet, you can fix this with a sheet worker to always use the full proper row id, so that it'll always work. But I cant offer a code solution to do that without seeing the complete repeating section code. In short though: you'd have a hidden attribute to contain the row id, and whenever a row is created, a change event would populate that with the correct rowid using the sheet worker function getSectionIds. Then your code above with have an attribute reference in place of the $0 pointing to that hidden attribute.   I have tried with attr_ and it didn't work. And with the $0 I dont know which row was rolled. It would be repeating_traits_$0_uses I believe, but I don't think that can solve it.
1595445891
Mech
Pro
Sheet Author
timmaugh said: I have a script (in dev) that -- in part -- interrogates the character sheet to help you construct the right kind of command line call. Like I said, it's in development, so not everything in the script works, but the xray interrogation works, so you can check it out. You can find it here . Copy the code and drop it into your game, naming the script "InsertArg". Once you're done with that, you can use the xray feature of the script. Enter the following command in the chat: !xray --[character name] ...where [character name] is the character you want to xray. Alternatively, you could provide a character id or token id and the script will work. The script will return all repeating sections of the character with api buttons to let you drill down on the elements within that section. (you might want to expand your chat, especially for the next step.) Clicking on one of those buttons will xray the corresponding repeating section, so you can see the interior elements. When you click a button, it will ask you what which repeating thing you want to xray (at what position). The positional numbers start at 0. (I think the positional value the script references is the appearance on the sheet, not the order the components were added, but I could be wrong.) Here is the result of clicking the "powers" xray button and picking slot 10 from the character I began xray-ing: I know that's a bit difficult to read, but you can see that it shows you all of the sub attributes associated with that repeating attribute. Where it detects that an attribute is executable, you will see 3 buttons. XRAY - will build an output of api buttons from this section using that item as the action to execute (think: cross-tab output); it will ask you what sibling attribute to use as the name on each button (and it will guess if it detects the characters 'name' in the sibling attribute name). VIEW - will show you the text of that attribute without executing it EXEC - will execute the attribute as if you had run it, in game Hopefully this helps you interrogate the sheet to find the pieces you need to push around and plug into your macro... post back if you have questions. (Just to say it again, this is not the finished version, so new versions will be coming) This is promising, I might try it. It does seem to look likeit can do the job. Does the script hhave other features I should know about??
1595449822

Edited 1595451197
timmaugh
Roll20 Production Team
API Scripter
The larger purpose of the script is to give you the ability to drop custom "hooks" (think: mailboxes) into other scripts so that you can change them on the fly in game... the common example I give is multiple target designations. I don't want a separate macro for a Fireball spell that targets 1 character, another macro for the same Fireball spell that targets 2, etc. The hook you drop into the existing script call becomes the argument you pass into the insertarg call, and it "delivers" the results to the mailbox in real time. So an ability named "Firestarter" that would normally read: !fireball --level#2 --tgt#@{target|Target 1|token_id}@{target|Tarket 2|token_id}@{target|Target 3|token_id} ...becomes... !fireball --level#2 --tgt#MyFancyHook When you want to run it, you'd run this line, instead: !insertarg --chat#Firestarter --MyFancyHook#gettargets(3) And it creates that output for you. Of course, you can't send the targetting command FROM the api, so in this case, it should realize that it can't send the chat directly (like you asked for), and should instead create an api button for you to initiate the call, yourself. I say, "should" because that's on my list of fixes to implement. All of that, however is under the !insertarg side of the script. Using !xray is much more straightforward.