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

How to pull a variable into a macro when the macro changes depending on what is added to the sheet by the player.

Sorry for the confusing title, I'm not sure how to easily summarise what I'm trying to do. I have a house rule set and I'm trying to create a character sheet for it from scratch. I want to automate as much of the sheet as possible from what the players enter into it and I'm having success so far, but I'm running into the limits of my knowledge. I have a weapon table which lists a number of different values for each weapon listed within it. At the end of each row I have a roll button. The character's ability with the weapon type factors into the roll and I want this value to be pulled from the skill list further down the sheet. The thing is, this changes depending on what kind of weapon it is. I don't want to pre-fill out different weapon types in the table and I'd rather not require the player to put their weapon skill in the weapon table as it complicates things and means there's two copies of the same skill to keep track of as they improve their skills. Have a look at the attached images to see what I mean. Below is the code I have so far. In the macro, it's the value for the "Attack roll" I want to be able to change. Thanks in advance for any help you can offer! <div class="container-weaponsHeader">         <div class="box-1">Weapon</div>         <div class="box-2">Type</div>         <div class="box-3">w/</div>         <div class="box-4">Damage</div>         <div class="box-5">Damage Type</div>         <div class="box-6">#Att</div>         <div class="box-7">Speed</div>         <div class="box-8">Range</div>         <div class="box-9">AP</div>         <div class="box-10">Ammo</div>         <div class="box-11">Roll</div> </div> <div class="container-weaponsRow1">     <div class="box-1"><input type="text" name="attr_weapon1" style="width: 200px;" /></div>     <div class="box-2">         <select name="attr_weapon1Type" style="width: 90px;"/>           <option value="Sword" selected="selected">Sword</option>           <option value="Knife">Knife</option>           <option value="Bow">Bow</option>           <option value="Crossbow">Crossbow</option>           <option value="Club">Club</option>           <option value="BAxe">Axe</option>           <option value="Polearm">Polearm</option>         </select>     </div>     <div class="box-3"><input type="checkbox" name="attr_hasWeapon1" value="1" checked="true" style="width: 30px;"/></div>     <div class="box-4"><input type="number" name="attr_weapon1Damage" style="width: 30px;"/></div>     <div class="box-5">         <select name="attr_weapon1DamageType" style="width: 90px;"/>           <option value="Slash" selected="selected">Slash</option>           <option value="Pierce">Pierce</option>           <option value="Bludgeon">Bludgeon</option>         </select>     </div>     <div class="box-6"><input type="number" name="attr_weapon1Attacks" style="width: 30px;" /></div>     <div class="box-7"><input type="number" name="attr_weapon1Speed" style="width: 30px;" /></div>     <div class="box-8"><input type="number" name="attr_weapon1Range" style="width: 30px;" /></div>     <div class="box-9"><input type="number" name="attr_weapon1AP" style="width: 30px;" /></div>     <div class="box-10"><input type="number" name="attr_weapon1Ammo" style="width: 30px;" /></div>     <div class="box-11">         <button type="roll" value="&{template:default} {{name= @{character_name} attacks with @{gender} @{weapon1} }} {{Initiative= [[@{initiativeScore}d2 -@{initiativeScore} +@{weapon1Speed} &{tracker}]] }} {{Attack roll= [[@{knifeScore}d2 -@{knifeScore}]] }} {{And does [[@{weapon1Damage}d2 -@{weapon1Damage}]] @{weapon1DamageType} Damage}}" name="roll_weapon1">         </button>     </div> </div> <div class="container-weaponsRow2">     <div class="box-1"><input type="text" name="attr_weapon2" style="width: 200px;" /></div>     <div class="box-2">         <select name="attr_weapon2Type" style="width: 90px;"/>           <option value="Sword" selected="selected">Sword</option>           <option value="Knife">Knife</option>           <option value="Bow">Bow</option>           <option value="Crossbow">Crossbow</option>           <option value="Club">Club</option>           <option value="BAxe">Axe</option>           <option value="Polearm">Polearm</option>         </select>     </div>     <div class="box-3"><input type="checkbox" name="attr_hasWeapon2" value="1" checked="true" style="width: 30px;"/></div>     <div class="box-4"><input type="number" name="attr_weapon2Damage" style="width: 30px;"/></div>     <div class="box-5">         <select name="attr_weapon2DamageType" style="width: 90px;"/>           <option value="Slash" selected="selected">Slash</option>           <option value="Pierce">Pierce</option>           <option value="Bludgeon">Bludgeon</option>         </select>     </div>     <div class="box-6"><input type="number" name="attr_weapon2Attacks" style="width: 30px;" /></div>     <div class="box-7"><input type="number" name="attr_weapon2Speed" style="width: 30px;" /></div>     <div class="box-8"><input type="number" name="attr_weapon2Range" style="width: 30px;" /></div>     <div class="box-9"><input type="number" name="attr_weapon2AP" style="width: 30px;" /></div>     <div class="box-10"><input type="number" name="attr_weapon2Ammo" style="width: 30px;" /></div>     <div class="box-11">         <button type="roll" value="&{template:default} {{name= @{character_name} attacks with @{gender} @{weapon2} }} {{Initiative= [[@{initiativeScore}d2 -@{initiativeScore} +@{weapon2Speed} &{tracker}]] }} {{Attack roll= [[@{swordScore}d2 -@{swordScore}]] }} {{And does [[@{weapon2Damage}d2 -@{weapon2Damage}]] @{weapon2DamageType} Damage}}" name="roll_weapon2">         </button>     </div> </div> <h3>Skills</h3> <div>     Initiative (Ref)     <input type="number" name="attr_initiativeScore" />     <button type="roll" value="&{template:default} {{name= @{character_name} rolls Initiative}}  {{Result= [[@{initiativeScore}d2 -@{initiativeScore}]]}}" name="roll_initiativeScore"></button> </div> <div>     Weapon - Knife (Ref)     <input type="number" name="attr_knifeScore" /> </div> <div>     Weapon - Sword (Ref)     <input type="number" name="attr_swordScore" /> </div>
I'm still trying to work this out. This is the button code:             <button type="roll" value="&{template:default} {{name= @{character_name} attacks with @{gender} @{weapon2} }} {{Initiative= [[@{initiativeScore}d2 -@{initiativeScore} +@{weapon2Speed} &{tracker}]] }} {{Attack roll= [[@{swordScore}d2 -@{swordScore}]] }} {{And does [[@{weapon2Damage}d2 -@{weapon2Damage}]] @{weapon2DamageType} Damage}}" name="roll_weapon2"> And it's giving the following errors: No attribute was found for @{Test character|weapon1attackscore} No attribute was found for @{Test character|weapon1attackscore} SyntaxError: Expected "[" but "e" found. Is anyone able to offer me a hand please? :)
1588173966
Wes
Sheet Author
I would change the value of the weapon1Type select to be the values of the skills entered by the player.         <select name="attr_weapon1Type" style="width: 90px;"/>           <option value="@{swordScore}" selected="selected">Sword</option>           <option value="@{knifeScore}">Knife</option>           <option value="@{bowScore}">Bow</option>           <option value="@{crossbowScore}">Crossbow</option>           <option value="@{clubScore}">Club</option>           <option value="@{baxeScore}">Axe</option>           <option value="@{polearmScore}">Polearm</option>         </select> This should give you your dynamically changing score in your rolls. Also I have no idea where: No attribute was found for @{Test character|weapon1attackscore} is coming from, as it shows up no where in the code you have posted.
Thank you! Your help led me to the solution! With your suggested code I changed the button code to <button type="roll" value="&{template:default} {{name= @{character_name} attacks with @{gender} @{weapon1} }} {{Initiative= [[@{initiativeScore}d2 -@{initiativeScore} +@{weapon1Speed} &{tracker}]] }} {{Attack roll= [[@{weapon1Type}d2 -@{weapon1Type}]] }} {{And does [[@{weapon1Damage}d2 -@{weapon1Damage}]] @{weapon1DamageType} Damage}}" name="roll_weapon1"> </button> and it now works as I wanted it to! Many thanks :D