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

A constant decreasing value in a macro

1523598485

Edited 1523598622
If your confused, what I am looking for (if its possible) to make a macro like for example using a wand with "x" amount of charges. Is there a way to to display the amount of charges with a numeric value that decreases everytime you click it. Like if i had a wand with 10 charges, then next time i click it will say 9 charges left, etc etc. I tried searching the forums and the only thing that even came close to what i was looking for was a round tracker counter.
1523603219
vÍnce
Pro
Sheet Author
Non-API macros only have read-only access to attributes.  As a Pro, you can use API scripts, so depending on which sheet you're using, there are companion scripts available for the Pathfinder Community and 5e sheets that can track resources. ie charges, arrows, uses, etc.  I believe the Ammo script was specifically written to handle resource tracking.
1523609074
GiGs
Pro
Sheet Author
API Scripter
If neither of those options are available, you can use the ChatSetAttr script to directly alter the wand charges, just include a line in the wand usage macro to activate it.
ok i am kinda new with the whole api stuff....and i am still kinda basic with macros. The only api i have used so far was one to import character sheets from pcgen into roll20. but I dont use that no more as I use Herolabs now and its so much easier (more expensive but easier). So if you could, maybe help me with the api to get it set up so that when I use a wand charge, or ranged weapon with ammo, i can have a better track of whats still available..
If you haven't already set up the ChatSetAttr, go to your game's page and in the settings menu (gear), go to API scripts.  There are two "kinds" of scripts: ones that you can automatically add to your game from the "Roll20 API Script Library", and they'll update as the authors update them, or you can manually add them.  In this case we're going to add it from the "Roll20 API Script Library" drop down. Find "ChatSetAttr" and click "Add Script".  You should see some stuff happening in the API Output Console. There are several ways to use macros. First, from a character sheet button.  Depending on the sheet, those may or may not allow you to edit them.  Another way is from the Attributes & Abilities tab, where you can add an Ability macro.  Also you can run any macro by simply typing (or pasting it) into the chat.  And of course there's also the Macros tab  (where chat, and character sheets are). If a character has a "wands-charges" attribute with a value of, say, "42", then you can type this into the chat or make a macro: !setattr --sel --wand-charges|41 You have to have the character selected for this to work.  It's also not very dynamic, as it only ever changes the value to "41".  So try the following: !setattr --sel --wand-charges|[[@{selected|wand-charges}-1]] This sets the selected character's "wand-charges" to the existing value minus 1.  The "[[" and "]]" make it an in-line calculation.  You could even do something like: !setattr --sel --wand-charges|[[@{selected|wand-charges}-1d6]] Which would reduce the value by 1d6. There's a whole lot more you can do with this and a lot of different ways you can put it all together, but I hope this got you started.
1523650210

Edited 1523650303
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Based on your use of pcgen, I'm assuming you're playing Pathfinder. If you are using the community sheet, I'd highly recommend trying the Pathfinder companion. There is a detailed users manual as well.
1523667635

Edited 1523667875
Scott C. ,you are right and my appologies for not stating that I was playing pathfinder. rookie mistake lol. And to Moonpie, I tried your idea cause i like where it was going. but coming up with problems. but before I go into the problem, i would also like to add that i use herolabs to import the character. So I am hoping that, that isnt whats causing my problems. And this paticular character was imported before adding the script you mentioned. Again I am hoping that isnt part of the problem. So on to the problem. I made a complete macro making look nice with the proper info. And with my token target it kinda works.......once. In my attributes I labeled it Wand-Cure (for simplicity) and set the value at 50/50 as it is a new wand. (also in general just a new character entering this campaign)  So here is the macro i created: &{template:pf_attack} {{name=Wand of Cure Light Wounds}} {{subtitle=Laura taps her wand on the wounded}} {{Heals for = [[1d8+4]]}} {{Charges left on wand}} {{!setattr --sel --Wand-Cure|[[@{selected|Wand-Cure}-1]]}} And this is what i get in the chat box: (if you can read it) I would like it to not show the string but only the value it produces for how many charges left.....and also that it only reduced the value once to 49, and every time i clicked again it would stay 49 as it is not changing the value in the attributes.
1523667852
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
API commands need to be on their own line, not contained in a template.
so i cant use a template at all to use the api command....or can I just not add the {{ }} to put it out of the template?
1523668206

Edited 1523668306
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Just put it on a new line after the template Edit:Also, PFC will guide you through this setup and do it for you automatically. Edit 2v not via chatsetattr obviously
ok....i kinda got it working.....just one last question. As i said i am kinda new with macros and still learning alot and to me no better way to learn then ask. I have focusing issues when trying to read long paragraphs  and such that i lose interest after a few sentances. Moons pies post was the longest ive read in a long time lol. But on to the question, in a macro, can you pull an attribute value? so that way in the macro it will show  and btw with the scrip moon pie suggested, the character sheet is v3
1523669105
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Yep, @{attribute_name}. see the wiki for full details:&nbsp;<a href="https://wiki.roll20.net/Macros" rel="nofollow">https://wiki.roll20.net/Macros</a>
1523669786

Edited 1523669822
woot I got it all figured out now....it works perfectly. Here is my Fished macro product &{template:pf_attack} {{name=Wand of Cure Light Wounds}} {{subtitle=Laura taps her wand on the wounded target}} {{Heals for = [[1d8+4]]}} {{Charges left on wand [[@{Alaura Distram|Wand-Cure}-1]]}} !setattr --sel --Wand-Cure|[[@{selected|Wand-Cure}-1]] Thank you guys for your help...you guys are awesome -thumbs up-