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] Point in the right direction

1473576341
Andrew C
Marketplace Creator
I'm pretty sure I should be looking at the Ammo Tracker API for this, but I'm VERY new to Java.  I've dabbled in some script/programming before, so I'm not completely useless... but what I am looking for is to have a "Spells Per Day" function for Sorcerers in D&D3.5E. So when the spell macro is called, I would need the API to then deduct one from the correct Level of Spells Per Day.  That's pretty much the only thing I need the API to do since the rest is just information dumping or calculating from Attributes.
1473580004

Edited 1473580013
Tetsuo
Forum Champion
Are you working off the 3.5 sheet? if so, are you trying to adjust an attribute on that sheet (The spells per day field)? If so, there's an api for you!  Here it is! (You were right, its the ammo script!)  [ token ID ] [ spells1 ] [ 1 ] Would add 1 to your first level spell attribute. (Replace token id with your token's id)
1473586830
Andrew C
Marketplace Creator
can you automatically "know" token_id from within a Character sheet? Can you replace [token_id] with something like @{character|character_id} ?
1473587987
Tetsuo
Forum Champion
you can. You could also use @{selected|character_id} or @{selected|token_id} to pull the associated id from whatever token you have selected.
1473588698
Tetsuo
Forum Champion
So, for example. I play a kineticist, and I use the following macro to increase its burn by 1 !ammo @{Kyra|character_id} burn 1 Note that I made a special attribute on the sheet called burn, but this works for almost any attribute. So yours would look something like !ammo @{wizard|character_id} spells1 1  you can also use negative numbers to decrease the attribute. So, if you can cast 5 1st level spells, you would set it to 5, and run !ammo @{wizard|character_id} spells1 -1 That would change your spells1 slot to 4, and output "Wizard uses 1 ammo and has 4 remaining."
1473590901
Andrew C
Marketplace Creator
Okay, that's fine. I can then just load !ammo @{character|character_id} spells1 -1 each time they cast a spell from their sheet. Easy enough. I assume I would also have to get under the hood of the Ammo API if I wanted to change the cosmetics of that output to say: "@{character|character_name} has [[output]] 1st level spells remaining" OR would the API execute the subtraction fast enough you could: ((Spell text/junk)) !ammo /w (player) @{character|character_name} has @{spells1} 1st level spells remaining Because I know the API does do some stuff in the background of other processes. (And would you have to get under the hood to 'shut it up'?)
1473591128

Edited 1473591257
Tetsuo
Forum Champion
 You can execute it at the end of another macro, but the player that executes the command already gets a whisper from ammo for the output. I don't personally know how to make it whisper to someone else. Yes, I'm sure you can tinker under the hood to change the cosmetics of the output fairly simply.
1473592323
Andrew C
Marketplace Creator
Okay. No I didn't mean for it to tell another player entirely, I just didn't know if you could 'silence' the API swiftly, or if you could easily amend the output of the API.  I haven't handled Javascript but from the looks of it, it reminds be a bit of VBasic.
1473592735

Edited 1473592753
Tetsuo
Forum Champion
I personally have no coding experience other than macros for roll20. Anything like modifying the api script is beyond my knowledge. As it stands, the macro simply whispers to whoever executed it. Best of luck with any changes you'd like to make!
1473600752
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
I use Aaron's ammo script, and have looked under the hood a little. Amending it so that the output is more appropriate for whatever you are actually changing shouldn't be too hard. As for your question about how quickly the api executes. having the api command in the same macro as the output that you want changed will not cause the final output to be changed as it's all sent to the chat parser/api at the same time. What I wound up doing for my ammo using players was doing essentially this: ((Spell text/junk)) !ammo @{character_id} spells1 -1 /w (player) @{character|character_name} has [[@{spells1}-1]] 1st level spells remaining Also, as demonstrated above, if you are putting this in a character's abilities (e.g. in an ability on their attributes/abilities tab or in macro text on their sheet) you don't need to use the selected or charactername specification in the attribute call. You could also put a query in there for number of ammo used if you wanted and then it would be dynamic for a case where they might use more than one ammo at a time.
1473605029
Andrew C
Marketplace Creator
Yeah I was going to load it as part of the Spell Macro fields that Dianne P has made.