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

[Help/Request] Ammo script: Alternative to row ID for repeating sections


Edited 1603083171
I've just noticed some really odd behaviour that hasn't come up in my game until now. I've been using the script for my player's consumable items, creating a button in a consumable's description like below, which they can use to spend one item: [Interact](!ammo @{character_id} repeating_items-readied_-MELYuIZwnJYrjtKGrNO_readied_quantity -1 @{readied_item}) This seemed to work fine until tonight, some players got their hands on several types of consumables, and any items added beyond somewhere around the 10th item in the repeating section give this error when trying to use the button for Ammo: I tried changing the commands to use the row number instead, like: [Interact](!ammo @{character_id} repeating_items-readied_$14_readied_quantity -1 @{readied_item}) But again, a 'not found' error: Moving these to the upper rows seemed to cause even more issues. Aside from row $0, commands using row number seem to affect the row beneath them, so there's no way to affect row $1 this way, as using $1 affects row $2 while using $0 affects row $0. Meanwhile, using row IDs only works for items added before the section reached 10 or so items. EDIT: I tried clearing out the entire section and re-adding everything, making sure all the consumables were added first, but using the row number in the commands still seems to stop working after row $1. For example, using $4 affects row $5 while changing the command to use $3 affects row $3. So far using row ID is working up until the 5th row. Is there another way I can use Ammo to adjust repeating sections? Or could it be adjusted to search for a value within a specific repeating section, like the item name in a row?
The Aaron
Roll20 Production Team
API Scripter
That's really quite strange. I can't look into it right now, or possibly this week. It's odd it wouldn't work for tenth and later rows. I confess I can't recall ever trying it on that many rows. Which character sheet are you using?
I'm using the Pathfinder Second Edition by Roll20 sheet. The commands are for the Readied section of the inventory. I tested a bit more and the 10th row thing was just a coincidence. Adding testing on a new sheet, sometimes it stops working after 4 or 5 rows, sometimes more. I can't figure out a cause yet. But I tried using ChatSetAttr commands to adjust the quantities for the same row IDs that Ammo wouldn't recognize, and it worked without issue. Here's what I changed the example from my first post to: [Interact](!modbattr --charid @{character_id} --repeating_items-readied_-MELYuIZwnJYrjtKGrNO_readied_quantity|-1) Idk what messes with Ammo's ability to use the ID but doesn't affect ChatSetAttr.
Sheet Author
API Scripter
Is it specifically an ammo problem, or general API being flakey? There's a bug thread of reports about people just finding the API stops working for a while with no errors. Something inconsistent like this could be the same thing.
Seems like they resolved that issue, but I can't tell if it's related. I just tested an item that was giving me an error for a row ID-based Ammo command yesterday, and now it's working fine. But now I'm getting a 'not found' error when using row number instead of ID. I was only getting these for row-IDs before. Plus, when using ChatSetAttr to adjust the same values using either ID or number it doesn't have an issue.

Edited 1603152701
Either way I think being able to designate a row by a specific attribute value would have a lot of benefits and make the script a bit easier to use. Instead of the command looking for just 'Attr' you could add vertical bars to look for 'Section|Key|Value|QuantityKey'. So a command could either look for an attribute like this !ammo @{character_id} hero_points -1 Hero Point or look for a repeating item like this !ammo @{character_id} items-readied|readied_item|daggers|readied_quantity -1 dagger That way the command could be copied into multiple items without having to find each item's row ID or counting on keeping it in the same row order. You could use a macro that queries the Value so you just have to type the name !ammo @{selected|character_id} items-readied|readied_item|?{Ammo}|readied_quantity ?{Spend or retrieve?|spend,-|retrieve,+}?{How many|0} ?{Ammo} or even set it to pull the name value directly from the row attribute to make it more universally copied !ammo @{character_id} items-readied|readied_item|@{readied_item}|readied_quantity -1 @{readied_item} I tried borrowing the attribute lookup from this script the Aaron wrote and implementing into Ammo, but kept running into issues that were beyond me <a href="" rel="nofollow"></a>