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

SWADE Ammo Tracking TypeError

1647532930

Edited 1647534262
Yuki
Pro
Hello! I'm using the Official Pinnacle Character sheet and have the Ammo API loaded and I am struggling to get a macro working that can actually track ammo appropriately. I have the below code and I keep getting errors and I'm not sure where I'm going wrong. !ammo @{character_id} repeating_gear_$0_item -1 Buckshot When I type in the following code @{character_id|repeating_gear_$0_item} It brings up the correct item in Gear and posts it to the chat "Bucklshot"  "Buckshot" so I feel like the repeating script is correct but I get this error constantly when trying to track ammo:  TypeError: Cannot read properties of undefined (reading 'substring') When I hover over the Quantity, there are brackets and it looks like this [quantity] and I'm not sure if with this specific sheet there's a different script I need to call? I'm a novice when it comes to these things so please go easy on me! Thanks in advance!
1647533448
The Aaron
Roll20 Production Team
API Scripter
Where is that error showing up?   You said "Bucklshot", but are passing "Buckshot", is that just a typo?
1647534203

Edited 1647534387
Yuki
Pro
The error is showing up in the chat. Also the Buckshot was a typo on my end, not inside the campaign itself. No typo in game, still having this issue popup though. The blue stuff is what happens when I type the following code: @{character_id|repeating_gear_$0_item} @{character_id|repeating_gear_$1_item} For Clarity, item 0 is Buckshot and item 1 is Slug, edited my initial post to reflect that as well as fixed the typo.
1647536223
The Aaron
Roll20 Production Team
API Scripter
You need to run it like this: !ammo @{Cupcake|character_id} repeating_gear_$0_item -1 Buckshot You can only use the short form @{character_id} in abilities on characters.  And in chat when you use @{CharacterName}, you need to specify what you want from the character with |<attribute>.
1647539381

Edited 1647541975
Yuki
Pro
Maybe it's because I'm new but with the |<attribute>, what I'm wanting is for the Quantity of an item in my Gear section to be reduced. When I hover over the item, it displays the same repeating code as what's after it. I'm a little confused as to what should go after the |. Thank you for helping me so far! Here's what I entered into the chat and here's the error that was returned: !ammo @{Cupcake|Buckshot} repeating_gear_$0_item -1 Buckshot Edit: I tried adding the ammo to the powers sections to see if that would be easier to track and when I try to call it, I get the following error (67 is how many shells are in the inventory):