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

Use ChatSetAttr to adjust repeating inventory

1645385785
Pak
Pro
I'm trying to use the ChatSetAttr API to increment the item count for specific items on multiple character sheets. I'm using OGL 5E.  The character owners like to move their items around on their character sheet so I decided to look up the specific item id for each item I want to increment. Contextually, I'm running Tomb of Annihiation and reducing insect repellent by 1 for each morning they apply a fresh dose. I use the codes below all run at the same time... Sometimes it runs as expected. But most of the time it only runs 1 or 2 of the commands... ie. player 1 and player 3 only increment out of 6 total players... !modattr --name Rol Ulfgar --repeating_inventory_-MtYqgfYvZLjo0T3glHv_itemcount|-1 !modattr --name Dain Ironfist --repeating_inventory_-MNJSx-sXFpNasIApWY3_itemcount|-1 !modattr --name Thalanil Zinvaris --repeating_inventory_-MNJSvHVNBjGZySHTZWq_itemcount|-1 !modattr --name Inidil --repeating_inventory_-MQcSte2brj76cqEhs3h_itemcount|-1 !modattr --name Brenna Elden --repeating_inventory_-McdiVpYoIA8JdNxJ675_itemcount|-1 Any ideas why the result would be so inconsistent? Is there a better way to "nest" each increment command that would result in a more consistent result?  Not sure what I'm doing wrong...
1645389047
GiGs
Pro
Sheet Author
API Scripter
There's a glitch been mention quote a few times on the fourm that multiple API calls often fail - only 1 or 2 get run. ChatSetAttrs allows you to combine multiple commands into a single API call. IIRC the syntax is !modattr { --name Rol Ulfgar --repeating_inventory_-MtYqgfYvZLjo0T3glHv_itemcount|-1 --name Dain Ironfist --repeating_inventory_-MNJSx-sXFpNasIApWY3_itemcount|-1 --name Thalanil Zinvaris --repeating_inventory_-MNJSvHVNBjGZySHTZWq_itemcount|-1 --name Inidil --repeating_inventory_-MQcSte2brj76cqEhs3h_itemcount|-1 --name Brenna Elden --repeating_inventory_-McdiVpYoIA8JdNxJ675_itemcount|-1 }
1645392248
Pak
Pro
Thanks GiG! Yeah. I forgot to mention I tried it the way you suggested before as well and got the same inconsistent results.  But I used --charid instead of --name.  I wasn't sure if --name would give me more consistent results. Nonetheless, they both ended up in similar errors. Before posting, I tried: !modattr { --charid @{Rol Ulfgar|character_id} --repeating_inventory_-MtYqgfYvZLjo0T3glHv_itemcount|-1 --charid @{Dain Ironfist|character_id} --repeating_inventory_-MNJSx-sXFpNasIApWY3_itemcount|-1 --charid @{Thalanil Zinvaris|character_id} --repeating_inventory_-MNJSvHVNBjGZySHTZWq_itemcount|-1 --charid @{Inidil|character_id} --repeating_inventory_-MQcSte2brj76cqEhs3h_itemcount|-1 --charid @{Brenna Elden|character_id} --repeating_inventory_-McdiVpYoIA8JdNxJ675_itemcount|-1 }
1645395187

Edited 1645395201
Pak
Pro
So, I played around with multiple ways to swizzle the syntax. Below worked repeatedly and consistently !modattr {{ --name Rol Ulfgar --repeating_inventory_-MtYqgfYvZLjo0T3glHv_itemcount|-1 }}, !modattr {{ --name Dain Ironfist --repeating_inventory_-MNJSx-sXFpNasIApWY3_itemcount|-1 }}, !modattr {{ --name Thalanil Zinvaris --repeating_inventory_-MNJSvHVNBjGZySHTZWq_itemcount|-1 }}, !modattr {{ --name Inidil --repeating_inventory_-MQcSte2brj76cqEhs3h_itemcount|-1 }}, !modattr {{ --name Brenna Elden --repeating_inventory_-McdiVpYoIA8JdNxJ675_itemcount|-1 }}
1645396051

Edited 1645396275
GiGs
Pro
Sheet Author
API Scripter
How weird. Good discovery. When I need to to affect multiple characters, I usually use the --sel operator, and select the characters tokens. That lets me avoid having to hardcode character names, so i dont have to update the macro when the group changes. I havent seen an issue doing it this way (it's just one !modattr command). Though that won't work in your case since you need repeating section row IDs. Maybe you could store them in the resources section: I don't use the sheet, but I think they aren't repeating sections (at least the first one or two), so you won't need different IDs per character.
1645402412
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Just in case you decide to go that route: The first two resources are indeed regular attributes, not repeating ones. @{class_resource} @{other_resource}
1645408298
Pak
Pro
Thanks Keith and GiGs. I started out using resources at first.  But each player wanted things shown differently on their respective sheet.  One player didn't want to see rations and such in the resources and others didn't mind resource tracking but wanted to see it in a specific location.  I didn't want to enforce a specific format on them so I figured I'd choose the more complex way of tracking the item in question while at the same time not taking away their sheet layout "flexibility". I spoke to soon on the last code I shared.  I was able to get the API to only increment a portion of the characters listed on the list.  But it took 4 or 5 tries to get it happen vs. my original shared code that bugged out 90% of the time.  It's almost like the API isn't responding as fast as each command I run.  Player 1 will increment and the last player (#5) will increment.  But the players in between get skipped. Or the next time I try, only the last player increments and all the rest are skipped.  I don't recall a situation where any of the players in the middle of the list are randomly incremented.  Not sure if that's just coincidence or not... I did try the --sel operator out of sheer desperation, which worked, but spit out other errors.  It cross referenced every repeating item I listed against each player I selected.  When it couldn't find a matching unique row ID for the character, it just spit out a could not match error. So if I selected 5 players and had 5 unique ID's to increment, it resulted in 20 "no match found" errors, but 5 successful increment messages.  So it's another way to circumvent the problem but isn't the most efficient nor elegant. Worst case I'll just revert back to reminding the players to "manually" track their items. Thanks again for the inputs!
1645445769
GiGs
Pro
Sheet Author
API Scripter
This is one of those situations where as GM you say, "track those things in your resources" and no discussion about it. If they want it to be tracked automatically, they have to do it the way it's least trouble for you.
1645446089
Pak said: Thanks Keith and GiGs. I started out using resources at first.  But each player wanted things shown differently on their respective sheet.  One player didn't want to see rations and such in the resources and others didn't mind resource tracking but wanted to see it in a specific location.  I didn't want to enforce a specific format on them so I figured I'd choose the more complex way of tracking the item in question while at the same time not taking away their sheet layout "flexibility". I spoke to soon on the last code I shared.  I was able to get the API to only increment a portion of the characters listed on the list.  But it took 4 or 5 tries to get it happen vs. my original shared code that bugged out 90% of the time.  It's almost like the API isn't responding as fast as each command I run.  Player 1 will increment and the last player (#5) will increment.  But the players in between get skipped. Or the next time I try, only the last player increments and all the rest are skipped.  I don't recall a situation where any of the players in the middle of the list are randomly incremented.  Not sure if that's just coincidence or not... I did try the --sel operator out of sheer desperation, which worked, but spit out other errors.  It cross referenced every repeating item I listed against each player I selected.  When it couldn't find a matching unique row ID for the character, it just spit out a could not match error. So if I selected 5 players and had 5 unique ID's to increment, it resulted in 20 "no match found" errors, but 5 successful increment messages.  So it's another way to circumvent the problem but isn't the most efficient nor elegant. Worst case I'll just revert back to reminding the players to "manually" track their items. Thanks again for the inputs! Not only is there a long standing bug they have never fixed where api commands only fire once out of a macro and it ignores most of the others, but now in the chat input box for pasting a live set of commands roll20 now ignores the majority of the paste if its using api calls, attributes, /fx, /emote, and other non normal chat line breaks.  
1646405615

Edited 1646409038
Pak said: Thanks Keith and GiGs. I started out using resources at first.  But each player wanted things shown differently on their respective sheet.  One player didn't want to see rations and such in the resources and others didn't mind resource tracking but wanted to see it in a specific location.  I didn't want to enforce a specific format on them so I figured I'd choose the more complex way of tracking the item in question while at the same time not taking away their sheet layout "flexibility". I spoke to soon on the last code I shared.  I was able to get the API to only increment a portion of the characters listed on the list.  But it took 4 or 5 tries to get it happen vs. my original shared code that bugged out 90% of the time.  It's almost like the API isn't responding as fast as each command I run.  Player 1 will increment and the last player (#5) will increment.  But the players in between get skipped. Or the next time I try, only the last player increments and all the rest are skipped.  I don't recall a situation where any of the players in the middle of the list are randomly incremented.  Not sure if that's just coincidence or not... I did try the --sel operator out of sheer desperation, which worked, but spit out other errors.  It cross referenced every repeating item I listed against each player I selected.  When it couldn't find a matching unique row ID for the character, it just spit out a could not match error. So if I selected 5 players and had 5 unique ID's to increment, it resulted in 20 "no match found" errors, but 5 successful increment messages.  So it's another way to circumvent the problem but isn't the most efficient nor elegant. Worst case I'll just revert back to reminding the players to "manually" track their items. Thanks again for the inputs! Probably not the cleanest solution but ChatSetAttr does have the wonderful --silent operator which stops it from spitting out error or success messages in chat so worst come to worst you can use the --sel operator and just silence it so it doesn't throw out 20 errors each time
1646496079
Pak
Pro
Kilidian said: Pak said: Thanks Keith and GiGs. I started out using resources at first.  But each player wanted things shown differently on their respective sheet.  One player didn't want to see rations and such in the resources and others didn't mind resource tracking but wanted to see it in a specific location.  I didn't want to enforce a specific format on them so I figured I'd choose the more complex way of tracking the item in question while at the same time not taking away their sheet layout "flexibility". I spoke to soon on the last code I shared.  I was able to get the API to only increment a portion of the characters listed on the list.  But it took 4 or 5 tries to get it happen vs. my original shared code that bugged out 90% of the time.  It's almost like the API isn't responding as fast as each command I run.  Player 1 will increment and the last player (#5) will increment.  But the players in between get skipped. Or the next time I try, only the last player increments and all the rest are skipped.  I don't recall a situation where any of the players in the middle of the list are randomly incremented.  Not sure if that's just coincidence or not... I did try the --sel operator out of sheer desperation, which worked, but spit out other errors.  It cross referenced every repeating item I listed against each player I selected.  When it couldn't find a matching unique row ID for the character, it just spit out a could not match error. So if I selected 5 players and had 5 unique ID's to increment, it resulted in 20 "no match found" errors, but 5 successful increment messages.  So it's another way to circumvent the problem but isn't the most efficient nor elegant. Worst case I'll just revert back to reminding the players to "manually" track their items. Thanks again for the inputs! Probably not the cleanest solution but ChatSetAttr does have the wonderful --silent operator which stops it from spitting out error or success messages in chat so worst come to worst you can use the --sel operator and just silence it so it doesn't throw out 20 errors each time Hi Kilidian.  I actually like that idea.  Too bad there isn't an option to just silence the errors.  --silent suppresses the normal output, but still shows errors.  --mute suppresses both the normal output AND the errors.  I need an option that just suppresses the errors.  I don't mind seeing the normal output.