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

[Script] Ammo - Automated ammunition management in a character attribute.

1414280541

Edited 1414280672
ok now that ive buttered you up..... HAAAALP! lol ok so I just got home from work and im attempting to get this script to work... First I created an attribute called "Bolts" and filled in the min/max as "20/20" Then I wrote the command "!ammo <@{selected|token_id}> <Bolts> <-1> and i got this.. Character/Token id [] is not valid. Please be sure you are specifying it correctly, either with selected|token_id or copying the character id from: !get-represents selected|token_id So I used !get-represents [token_id] And nothing happened Then I checked my API Output and saw.... SyntaxError: Expected "[" but "o" found. Now im all like "Arrrgh" So I wrote this post.... P.S. I had the character selected each time I got the errors. P.S.S. I used just @{selected|token_id} and got -JZ5xa1-bqNJg28jKHf1, but this didnt work when I tried to use it for the <id> parameter.
1414282940
The Aaron
Roll20 Production Team
API Scripter
Leave the < and > off. That's just notation for a required value. [ and ] are notation for an optional value. Sorry about that! Try this: !ammo @{selected|token_id} Bolts -1 if that doesn't work, PM me an invite and I'll jump in and help you!
it made a lair out of me... lol i knew the < and > were just filler but I didn't get any results the 1st time I tried. Meh no big deal, works now :) Thanks again Aaron... Rocking awesome Mod
Hey did you ever get the recovery and name options implemented?
1414291817
The Aaron
Roll20 Production Team
API Scripter
About 50% done with them. Need to finish it up. :)
Aaron I have a suggestion, So i'm using this for daily powers, I was wondering if there was a way i could make a macro usable by the players or I that would refill them all to max (after they rest for the day). This is what I currently have.... !ammo -JW5LgN-6FtwAsNG-9gr Firebolt 20 !ammo -JW5LgN-6FtwAsNG-9gr Channel 20 This is for my Cleric player to refresh his channel energy and firebolt domain power, now the problem is, if HE uses it, it returns and error saying he's trying to add over the max, and if I use it, it disregards the established Max. Any idea's on making it give a "back to full" result? Or is this something your working on in the new version?
1414766246
The Aaron
Roll20 Production Team
API Scripter
I'll add it to the list. =D In the interim, you can change lines 25-32 to this (the part in bold): } else if( adj > max) { if(!isGM(playerid)) { adj = max; amount = (adj-val); } } Then, for players, it will just bound to the max for the attribute and not warn about the overage. =D
1414767707
The Aaron
Roll20 Production Team
API Scripter
For that matter, you could do: !ammo -JW5LgN-6FtwAsNG-9gr Firebolt [[ @{Bob|Firebolt|max}-@{Bob|Firebolt} ]] without modification. You'd have to hard code the character name (Bob in the above case), but it would work.
Nice I see what you did there, Minus the current, from the Max, then add the result. Very clever.... but im not surprised from a Man that can pull off the "people's eyebrow" as well as the Rock himself, in his profile pic.
1414775816
The Aaron
Roll20 Production Team
API Scripter
Hahaha! The People's Eyebrow! I've never heard that before! I do love the Rock, though I think I've been doing the eyebrow thing just about as long. :)
Any update on the !ammo name feature yet?
1415213547
The Aaron
Roll20 Production Team
API Scripter
I was working on it last night, it is next on my list of updates to wrap up.
@Aaron, awesome glad to hear it. I tried Paul's tracker mod, which works great for being universal, but instead of having the extra attributes I'd rather have it reflect on the character sheet instead. With yours, I am able to do that perfectly, it just says ammo when I'd like it to say "superiority die" or "spell slot". Thanks for the script, I appreciate and respect the effort put into it.
1415220385
The Aaron
Roll20 Production Team
API Scripter
Cool. =D I just went back through and made notes in the script for what I need to do. I'll try to wrap it up tonight. It's been lingering way too long and I want to get some little things wrapped up before the next big one! =D
That's awesome, thanks a ton man. I'm sure everyone else will be glad to see it updated as well. And more // notes the better, helps me understand what I'm changing! I'm still new the API stuff, but plenty of coding background to understand it. Just haven't gotten around to making my own scripts yet. ;)
1415220757
The Aaron
Roll20 Production Team
API Scripter
In that case, I highly recommend Javascript: The Good Parts by Douglas Crockford . It's well written, fast to read, and will really focus you on writing great Javascript. =D
Will definitely check it out, thanks again!
Bump? :D Not quite sure of the etiquette of these forums. But I'm anxouisly waiting for the update on this one.
1415796980
The Aaron
Roll20 Production Team
API Scripter
No worries. :). I'm working on it still, but got slightly bogged down. Soon though. :)
Im having issues to input a die value for this. Like !ammo @{selected|token_id} ammo d6 doesnt work. [[d6]] doesnt work. [d6] produces a die roll, but still doesnt add into it.
@The Aaron, is there a way to have !ammo set the value to a specific number. Say I wanted to make a "reload" macro that sets player spell slots back to their max values, by dictating the value it should be?
1416234055
The Aaron
Roll20 Production Team
API Scripter
Jake: sorry for the delay, I was out of town. Passing with the double brackets should work. [[ ]]. If it doesn't, I guess PM me a join link and I'll check it out in situe. JonMixhael: try this: <a href="https://app.roll20.net/forum/post/1034829/#post-13" rel="nofollow">https://app.roll20.net/forum/post/1034829/#post-13</a>... I'll try to add a better method soon.
1416326107
The Aaron
Roll20 Production Team
API Scripter
So Jake, I figured out what the problem is... I've gotten confused about the version of the script. The development version I need to finish up has the code to accept rolls, but the version in the gist does not. I've updated your two copies to have that code and it should work fine for you. I'll update the gist here with that code for others and try to get the Ammo rewrite wrapped up soon.
1416326197
The Aaron
Roll20 Production Team
API Scripter
Update v0.11 -- Minor update to add formal support for inline rolls.
Glad I came to this thread! Thought I was going crazy. Got on the game to grab the command for you and it started working and i was like D: Oh s***. Was gonna apologize and try to figure out how I've been messing it up! Thank you so much!
1416335439
The Aaron
Roll20 Production Team
API Scripter
Haha. No worries. Probably should have PM'd you. :)
@Aaron, ok for that to work, I'd need 2 ability values? "spell_slots" and "spell_slots_max" ? If I understand that correctly.
1416403138
The Aaron
Roll20 Production Team
API Scripter
JonMichael (Vante) said: @Aaron, ok for that to work, I'd need 2 ability values? "spell_slots" and "spell_slots_max" ? If I understand that correctly. Probably, though you shouldn't have to. When you make an attribute, it already has two fields. Usually you are using the value field, but it has a max field as well. You just need to make sure both fields of the attribute are filled in. If you're using a character sheet, the sheet author needs to have correctly set up that field. That said, you could set up another attribute to use as the max value, and just use it where the |max attribute is used in the example.
1416418941

Edited 1416419058
Hrmmm, ok. Let me take a stab at this then. !ammo @{selected|token_id} Maneuvers [[@{selected|Maneuvers|max}-@{selected|Maneuvers}]] That's what I used, it gives me an error of: "Amount [$4] is not correct. Please specify a positive or negative integer value like -1 or 4." Officially confused.
1416419454
The Aaron
Roll20 Production Team
API Scripter
You need to grab the latest version of Ammo: v0.11 Previously, it would not evaluate inline rolls.
1416444925

Edited 1416445396
Well now I just feel silly.... Alright, is there an easier way (like a previous poster did) to make the Ammo message say the value it's changing instead of "ammo."
1416445239
The Aaron
Roll20 Production Team
API Scripter
hmm.. I'm not quite clear on what you mean. (and don't worry about feeling silly, I felt silly when I uploaded that version AFTER telling people how to use it... =D) Are you saying you want it to report the number remaining when it makes changes?
No no, that sounds complicated. What I need is much simpler! LOL I'll show it in code...hopefully that will help. !ammo @{selected|token_id} Maneuvers -1 Results: " Vante DeLeon uses 1 ammo and has 3 remaining." Desired: " Vante DeLeon uses 1 Maneuvers and has 3 remaining." Basically, instead of saying "ammo" it says the &lt;attribute name&gt;. Hopefully that makes sense!
1416446806
The Aaron
Roll20 Production Team
API Scripter
AH! Ok. Change line 39 to this: +'&lt;b&gt;'+chr.get('name') + '&lt;/b&gt; '+( (adj&lt;val) ? 'uses' : 'gains' )+' '+Math.abs(amount)+' '+attr.get('name')+' and has '+adj+' remaining.' You can basically replace ammo in with '+attr.get('name')+' anywhere you see it in a message.
1416446901
The Aaron
Roll20 Production Team
API Scripter
My next version, once I finish it, will allow you to provide a specific name for each individual attribute on a character by character basis.. just need to write it.. =D
Works perfectly the way I need it to! ME GUSTA! :D
1416448998
The Aaron
Roll20 Production Team
API Scripter
Hahahah. cool. =D
It's me, yet again! Is there way to flag for whispering a specific ammo result?
1416865112
The Aaron
Roll20 Production Team
API Scripter
Hmm... How do you mean? As in, only whisper if the attribute is a certain name?
I always seem to ask the hard questions.... I'm tracking multiple things really, on one character. I consider myself clever in this regard, but I do produce a lot of !ammo spam. My request is really to try and reduce some of that spam so that I'm the only one who sees certain results.
1417014860

Edited 1417017296
The Aaron
Roll20 Production Team
API Scripter
I see. So, would it work for you to have the ammo system just whisper to the player? Add this after line 11: who=getObj('player',playerid).get('_displayname').split(' ')[0], Then change lines 16, 25, and 37 (17, 26, 38 after adding the above line) to this: sendChat('Ammo', (isGM(playerid) ? '/w gm ' : '/w '+who+' ')
You sir, are awesome! I also have another problem I'm running into as well. LOL I'm good at this. ;)
1417015953
The Aaron
Roll20 Production Team
API Scripter
Bring it! =D
Ok for the event when you cannot add more than the max, the adjustment just stops. In the case where the quantity &gt; max, can we just =max? So it still makes the adjustment?
The Aaron said: I see. So, would it work for you to have the ammo system just whisper to the player? Add this after line 11: who=getObj('player',playerid).get('_displayname').split(' ')[0], Then change lines 16, 25, and 37 (17, 26, 38 after adding the above line) to this: sendChat('Ammo', (isGM(playerid) ? '/w gm ' : '\w '+who+' ') As for this change, some things I want to send to the GM, some I want to whisper to myself, is that option available? Like the power card scripts --whisper|self option.
1417017474
The Aaron
Roll20 Production Team
API Scripter
Just noticed I put the wrong slash, should be: sendChat('Ammo', (isGM(playerid) ? '/w gm ' : '/w '+who+' ') Change the block around line 25 to this: } else if( adj &gt; max) { max = adj; attr.set({max:max}); }
1417017554
The Aaron
Roll20 Production Team
API Scripter
JonMichael (Vante) said: As for this change, some things I want to send to the GM, some I want to whisper to myself, is that option available? Like the power card scripts --whisper|self option. Nothing is built in for that as yet. The GM gets notified if the player tries to adjust out of bounds currently, and still will with that change. What else did you want to send to the GM?
As I said before, I'm tracking a lot of stuff. Just some examples: Format: Items (who I want to whisper) Arrows (to ME) Spell_slots_l1 (To GM) I have a macro for short rest and long rest that replenishes the items. But I didn't want to spam the GM with all of it when I use it. Honestly, this is a minor issue and I feel like I'm hassling you, so if it takes major thought and changes don't worry about it. You've been awesome!
The Aaron said: Just noticed I put the wrong slash, should be: sendChat('Ammo', (isGM(playerid) ? '/w gm ' : '/w '+who+' ') Change the block around line 25 to this: } else if( adj &gt; max) { max = adj; attr.set({max:max}); } Changing line 25 adjusted my max value, instead of the available value.
1417021739
The Aaron
Roll20 Production Team
API Scripter
Oh! misunderstood. though you were saying you wanted to adjust the maximum to a new maximum. } else if( adj &gt; max) { sendChat('Ammo', (isGM(playerid) ? '/w gm ' : '') +'&lt;div style="padding:1px 3px;border: 1px solid #8B4513;background: #eeffee; color: #8B4513; font-size: 80%;"&gt;' +'&lt;b&gt;'+chr.get('name') + '&lt;/b&gt; does not have enough storage space for ammo. Needs '+adj+', but only has ' +'&lt;span style="color: #ff0000;"&gt;'+max+'&lt;/span&gt;.' +'&lt;span style="font-weight:normal;color:#708090;&gt;&#91;Attribute: '+attr.get('name')+'&#93;&lt;/span&gt;' +'&lt;/div&gt;' ); adj = max; } Just change the valid = false; to adj = max;