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

[Moldvay BECMI Sheet] Automatically subtract ammo

Hi everyone! I’m creating a custom version of the Moldway BECMI character sheet to apply some modifications. I’d like to add a way to automatically subtract ammunition when making a ranged attack. In the HTML, ranged attacks are not set as repeating sections, and each single attack has its own ammunition attribute that it refers to: <!-- BEGIN ranged weapon row 2--> <div class="sheet-row"> <div class="sheet-col-1-24"> <button type='roll' name="Attack_@{MissileWeaponName2}" value="&{template:odnd} {{combat=1}} {{name=@{Name}}} {{title=@{MissileWeaponName2} \n @{RangedDistance2}}} {{rangedattack=[[@{HitAC0}[THAC0] - (@{toHitRoll}[Dice Roll] + @{MissileToHit2}[Bonus] + @{Missile_Halfling}[Halfling] + (?{Bonus/Minus|0})[ADD'L BONUS])]]}} {{damage=[[@{MissileDmg_Die2}+@{MissileDmg_Bonus2}]]}}"></button> </div> <div class="sheet-col-1-16"><input class="inSmallNum_noBorder" type="number" name="attr_MissileAmmo2" value="0"></div> <div class="sheet-col-1-4"><input class="inMainTxt" style="width: 190px;" type="text" placeholder="-" name="attr_MissileWeaponName2"></div> <div class="sheet-col-1-7"><input class="inMainTxt" style="margin-left: 8px; width: 90px" placeholder="0/0/0" type="text" name="attr_RangedDistance2"></div> <div class="sheet-col-1-9" title="Scegli la distanza del target"> <select name="attr_RangeToTarget2" style="text-align: center; width: 80px;"> <option value="1">Corto</option> <option value="0">Medio</option> <option value="-1">Lungo</option> </select> </div> <div class="sheet-col-1-10 sheet-padr" title="Il Bonus magico verrà aggiunto in automatico sia al TXC che ai danni"><input class="inSmallNum_noBorder" style="margin-left: 4px" type="number" name="attr_RangedMagic2" value="0" step="1"></div> <div class="sheet-col-1-10" title="Il tuo bonus totale al TXC (Mod. Forza + Bonus Magico + Mod. Range)"><input class="inSmallNum_noBorder" style="margin-left: 4px" type="number" name="attr_MissileToHit2" value="[[@{RangeToTarget2} + [[@{MOD_DEX}]] + @{RangedMagic2}]]" disabled="disabled"></div> <div class="sheet-col-1-10" title="Scegli il dado-danno dell'arma"><input class="sheet-inSmallNum_noBorder sheet-center" type="text" name="attr_MissileDmg_Die2" value="d6"<br/></div> <div class="sheet-col-1-11" title="Il tuo bonus totale al Danno (Bonus Magico)"><input class="inSmallNum_noBorder" style="margin-left: 4px" type="number" name="attr_MissileDmg_Bonus2" value="@{RangedMagic2}" disabled="disabled"></div> </div> <!-- END ranged weapon row 2--> I tried modifying the roll’s value by adding a line that calls the ChatSetAttr script (installed in the campaign), but this command only works if the value contains only the ChatSetAttr call and not the attack roll. Basically, when I click the “roll” button, the sheet won’t recognize both commands at the same time — it only runs whichever one is written first (either the API command or the attack roll macro). Does anyone have ideas on how to make this work?
1764693129

Edited 1764694028
vÍnce
Pro
Sheet Author
Hi LU MASTER, were you using ChatSetAttr as an inline roll? <a href="https://wiki.roll20.net/Script:ChatSetAttr#Inline_roll_example" rel="nofollow">https://wiki.roll20.net/Script:ChatSetAttr#Inline_roll_example</a> There's really no need to use API for this anymore and it would be best handled by using CRP ( custom roll parsing , better CRP info on GiGs site: here ). Basically you use an action button to initiate the roll, a sheetworker process the roll using startRoll(), then the roll is sent to chat finishRoll()&nbsp; You can manipulate the roll as well as adjust attributes automatically and/or depending on the results. ie ammo reduction
vÍnce said: Hi LU MASTER, were you using ChatSetAttr as an inline roll? <a href="https://wiki.roll20.net/Script:ChatSetAttr#Inline_roll_example" rel="nofollow">https://wiki.roll20.net/Script:ChatSetAttr#Inline_roll_example</a> There's really no need to use API for this anymore and it would be best handled by using CRP ( custom roll parsing , better CRP info on GiGs site: here ). Basically you use an action button to initiate the roll, a sheetworker process the roll using startRoll(), then the roll is sent to chat finishRoll()&nbsp; You can manipulate the roll as well as adjust attributes automatically and/or depending on the results. ie ammo reduction Thank you so much vÍnce! I tried with the inline roll and it works… I had no idea you could even do that! As for the CRPs, it seems they’re related to the sheet workers. To be honest, even though I’ve tweaked a few character sheets, I’m not a programmer. I’m starting to get a feel for how CSS and HTML work, but with sheetworkers AND Java Script I’ve only managed to modify a few that were provided to me by The Aaron.
1764719675
vÍnce
Pro
Sheet Author
Great to hear.&nbsp; Nearly all my html, css, and js knowledge was learned on roll20 sheets.&nbsp; Lots of great people in the community have been integral to my sheet knowledge.&nbsp; Keep at it and ask questions when you get stuck. Cheers