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

Roll a defined roll by reference

March 23 (10 years ago)

Edited March 23 (10 years ago)
Kryx
Pro
Sheet Author
API Scripter
Original button code:
<button type="roll" class="sheet-roll" name="roll_MeleeAttack1" value="@{output_option} &{template:5eDefault} {{weapon=1}} {{title=@{meleeweaponname1}}} {{subheader=@{character_name}}} {{subheaderright=Melee attack}} {{attack=[[d20cs>@{meleeweaponcritrange1} + @{meleetohit1} + (@{global_melee_attack_bonus}) ]]}} {{attackadv=[[d20cs>@{meleeweaponcritrange1} + @{meleetohit1} + (@{global_melee_attack_bonus}) ]]}} {{damage=[[@{meleedmg1} + @{meleedmgbonus1} + (@{global_melee_damage_bonus})  + 0d0]] @{meleedmgtype1}}} {{critdamage=Additional [[@{meleecritdmg1}]] damage}} @{classactionmeleeweapon}}">Attack</button>
Reference button code:
<button type="roll" class="sheet-roll" value="%{MeleeAttack1}">Attack</button>

The reference doesn't work as it doesn't have the name. Is there a way to get the name in there or make it work in another way?
March 23 (10 years ago)
Kryx
Pro
Sheet Author
API Scripter
Follow up in the same vein:

I'd like to reference an attr that is set elsewhere and display it inside said button. The only way I know of doing that is to have an input inside of the button like so:
<button type="roll" class="sheet-roll" value="%{MeleeAttack1}">
  <input type="text" name="attr_meleeweaponname_quick1" value="@{meleeweaponname1}" disabled="disabled">
</button>
But an input inside of the button prevents clicking on the button itself.

Is it possible to just print out the text of the attr?
March 23 (10 years ago)

Edited March 23 (10 years ago)
Kryx
Pro
Sheet Author
API Scripter
For the button you can put the value in a hidden input:
<input type="hidden" name="attr_roll_MeleeAttack1" value="@{output_option} &{template:5eDefault} {{weapon=1}} {{title=@{meleeweaponname1}}} {{subheader=@{character_name}}} {{subheaderright=Melee attack}} {{attack=[[d20cs>@{meleeweaponcritrange1} + @{meleetohit1} + (@{global_melee_attack_bonus}) ]]}} {{attackadv=[[d20cs>@{meleeweaponcritrange1} + @{meleetohit1} + (@{global_melee_attack_bonus}) ]]}} {{damage=[[@{meleedmg1} + @{meleedmgbonus1} + (@{global_melee_damage_bonus}) + 0d0]] @{meleedmgtype1}}} {{critdamage=Additional [[@{meleecritdmg1}]] damage}} @{classactionmeleeweapon}}" disabled="true">

<button type="roll" class="sheet-roll" name="roll_MeleeAttack1" value="@{roll_MeleeAttack1}">
  Attack
</button>
And then reference it in another button roll as well:
<button type="roll" class="sheet-roll" value="@{roll_MeleeAttack1}">
  <input type="text" name="attr_meleeweaponname_quick1" value="@{meleeweaponname1}" disabled="disabled">
</button>

Still not sure how to get the name inside the button.