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

Ammo Script by The Aaron - "Refill All" Issue

Hello all! I'm using the ammo script to track spell slots. (Just labeling them as L1Spell, L2Spell, etc.) I've been able to change the ammunition values of specific players without needing their token/character to be selected just fine. However. I'm having some trouble setting up a "long rest" macro which would recover all of my players' spell slots in this system. The following line: !ammo -LJ0U2NCwfPBL09WgpQH L1Spell [[@{selected|L1Spell|max}-@{selected|L1Spell}]] kind of works. Its successfully runs, but only pulls the current and max of the selected token/character. I've tried changing the "@{selected" part to pull directly from the character in question, but I either get a syntax error or a "character not found" error. I know these character IDs are correct as I have used them in my example line, which technically operates successfully. Is there a more experienced macro user that could assist me with this? Additionally, I do have this line that almost works, but I get a "NaN" value error when it runs: !ammo -LJ0U2NCwfPBL09WgpQH L1Spell [[-LJ0U2NCwfPBL09WgpQH|L1Spell|max]-[-LJ0U2NCwfPBL09WgpQH|L1Spell]] L1Spell "(player) gains NaN L1Spell and has NaN remaining."
To further clarify, I'm trying to update all of my players' "ammo" at the same time and pull the current and max values for each character directly via their character ID, rather than having to select every character. Aside from the error I get with my attempt to write this into the macro, if I use the first line I showed you, it will only pull the current and max of that selected character (because the way it's written requires me to have a character selected) and those values are not the same for every character, which leads to improper gains or losses.
1533644260
The Aaron
Pro
API Scripter
I would suggest trying to get the character name based references working on their own: /w gm [[@{Bob the Slayer|L1Spell|max}-@{Bob the Slayer|L1Spell}]] so you can debug the character references.  By the time this gets to the API command, inline rolls have already been completed in the client, therefore any issues with them are (probably) not an issue in the API, but in the roll itself.  That makes it much easier to debug, honestly. =D In fact, you could write your entire macro whispering to the GM, get it looking right, then take all the whispering out: /w gm !ammo -LJ0U2NCwfPBL09WgpQH L1Spell [[@{Bob the Slayer|L1Spell|max}-@{Bob the Slayer|L1Spell}]] /w gm !ammo -KA1232S5ADAFadf5a62 L1Spell [[@{Alethea|L1Spell|max}-@{Alethea|L1Spell}]] ... etc.   Whispering it to yourself should make it easy to get working, but if it doesn't, definitely reach out.
I see what you're doing here. instead of putting the character ID in again, you're using the character's actual name. I'll see how well that works and tell you my findings.
Thank you! This seems to work. It's a big macro, so unfortunately when I remove "/w gm" not all of the lines show up in the chat box consistently, but after double-checking a few test runs I can confirm that the macro works as intended. Thank you for telling me about this debugging tactic! It's very helpful and I'm sure I might need it in the future.
1533690866
The Aaron
Pro
API Scripter
Awesome!  Glad you got it working!