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 failure in my script

so, ive spent hours over the last few moths figureing out how to do this modifiable attack script. cant make it look mor interesting, but hey, it works. now for auto ammo tracking, would be really useful. so,  ive litterally spent the past two hours working on this, and digging through the forums to figure it out. imput new data, test, nothing. repeat, nothing. help please!!. - ive got this script running and functioning for different weapons and attacks, its modifiable for different weapons, got  another variation for doing sneak attacks, i like these scripts for their adaptability and customization options. now how to make !ammo work?! - &{template:default} {{name=***FIRE PRIMITIVE PROJECTILE***}} {{RANGE 80/320'=[[1d20+@{MAM}+2 ]] [[1d20+@{MAM}+2]] }} {{HIT=  [[1D10+@{MDM} ]] }} {{ CRITICAL= MURDER TO DEATH [[2D10+@{MDM} ]] }} !ammo @{character_id} repeating_resource_$0_resource_right -1 round - you name it in the !ammo line, ive changed it still only get - THANKS FOR YOUR TIME AND ADVICE!!
THIS IS MY RESOURCES SECTION, AND I DO HAVE 45acp AS A RESOURCE IN MY INVENTORY
1. What game and character sheet template are you using? 2. Where is this macro being called from? Because you are using an attribute call without a reference, it has to be called from a character sheet. 3. What is the result of @{selected|repeating_resource_$0_resource_right} if you put that into chat with a selected token linked to that character?
Jarren said: 1. What game and character sheet template are you using? 2. Where is this macro being called from? Because you are using an attribute call without a reference, it has to be called from a character sheet. 3. What is the result of @{selected|repeating_resource_$0_resource_right} if you put that into chat with a selected token linked to that character? i popped that in selected the token, and sent it. got 100. manually lowered the middle number to 99, sent it again, and it sends back 99. huh, so that command references the correct spot, now how to make that number depreciate? im using the DnD 5th editon roll 20 sheet. the instructions for using the macro were, lacking.  !ammo  @{selected|token_id}  arrows -1 arrow   thats all the api instuctions give for an example. substituted the word "arrows" with "45acp" and "arrow" with "round" and nothing. just tried swaping out the @ part with your @ part, and nothing.
i think im onto something... im like a chimp with a pistol, ive figured out that if you push this lever it goes bang. why, or why it stops going bang, is a mystery. ive played around a lil, did this....{{!ammo  [[@{selected|repeating_resource_$0_resource_right}-1]] round }} and it did this, depreciating by one, but will not do so again...
Jarren said: 2. Where is this macro being called from? Because you are using an attribute call without a reference, it has to be called from a character sheet. Is the macro on a character sheet on the Attributes and Abilities tab, or a Collection Macro, or just something that you are cutting and pasting into the chat window?
all from the sheet.everything im doing is on the sheet. everything im trying to refence is on the sheet. this is the abilities and attributes tab. the code you had me test called from the character sheet tab, other rescources, second row, right hand box, as shown above.
1645853590

Edited 1645854346
Oosh
Sheet Author
API Scripter
Have you tried your ammo command with the character id? !ammo @{selected|character_id} @{selected|repeating_resource_$0_resource_right} -1 round There's also a small script here I wrote for someone for modifying resources on the 5e sheet. It might make your life easier, since you can find ammo types by name - you should be able to just plug an ammo name into your macros and it will find the right one and decrement it. I'd only just learned Javascript when I wrote that, but it appeared to work for the OP in the thread. A brief look over the code and there's nothing overly embarrassing jumping out at me. I think Tim also has repeating section name search in at least one Meta script. If you're already using the Meta toolbox, you should be able to skip using a specialised script altogether. Edit - if you do grab the findResource script, make sure you grab it from the raw paste data down the bottom - just focus the frame and hit ctrl-A. From the look of the highlighting on the main body text, pasteBin has mangled some apostrophes.
thanks for trying, nothing works. i copy and paste your code and get this when run in chat. run in the sheet, it does nothing. and i cannot make heads or tails of your paste bin or what im supposed to do with all that. ill just keep track by hand
1645892004
The Aaron
Roll20 Production Team
API Scripter
Try: !ammo @{selected|character_id} repeating_resource_$0_resource_right -1 round
thank you, that worked in chat. then i tried plugging it into my macro, and nothing. now it dont work in chat anymore either.
&{template:default} {{name=***FIRE PRIMITIVE PROJECTILE***}} {{RANGE 80/320'=[[1d20+@{MAM}+2 ]] [[1d20+@{MAM}+2]] }} {{HIT=  [[1D10+@{MDM} ]] }} {{ CRITICAL= MURDER TO DEATH [[2D10+@{MDM} ]] }} !ammo @{selected|character_id} repeating_resource_$0_resource_right -1 round @MAM references the attributes column. its my main attack modifier, which changes with level, so, got the universal modifyer. @MDM is main damage modifier. same reason.
What happens to the macro if you put the !ammo command on a separate line? &{template:default} {{name=***FIRE PRIMITIVE PROJECTILE***}} {{RANGE 80/320'=[[1d20+@{MAM}+2 ]] [[1d20+@{MAM}+2]] }} {{HIT=  [[1D10+@{MDM} ]] }} {{ CRITICAL= MURDER TO DEATH [[2D10+@{MDM} ]] }} !ammo @{selected|character_id} repeating_resource_$0_resource_right -1 round
golly, that thought, never occured to me. i have been laboring under the impression that the whole mass needed be together. wow, jeepers dude, wow. you guys are awesome!! thank you for your patience!!! damnit jim, im an electrician not a coder!!! roflol THANK YOU SO MUCH!!!
1646062924
The Aaron
Roll20 Production Team
API Scripter
Yup, just to clarify, Roll20 only sends api commands if the first character on a line is ! which is why it didn't work until you put it on the next line.