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

Implementing Reroll button (TFTL as example)

TFTL has a reroll mechanic which I am trying to emulate/adapt to my custom sheet. The roll-template is triggered by a button which has these values passed: {{reroll0=[@{translation_luck}](~@{character_id}|reroll[[@{body}+?{Bonus Dice|0}-@{upset}-@{scared}-@{exhausted}-@{injured}-@{broken}-0]])}} The @{translation_luck) refers to a hidden <input> which sits at the top of the document: <input data-i18n-value="Reroll" name="attr_translation_luck" type="hidden" value="Reroll32"/>  Which is further preceded by a bunch of <button> tags.  <button class="hidden" name="roll_reroll0" type="roll" value="&{template:tftl} {{name=Reroll}} {{character_name=@{character_name}}} {{reroll_dice=0}} {{roll=[[0d6>6]]}}"></button> Finally, in the rolltemplate itself: <div class="sheet-tftl-buttons">{{#reroll1}}{{#rollTotal() roll 0}}       {{reroll0}}       {{/rollTotal() roll 0}}{{#rollTotal() roll 1}}       {{reroll1}}       {{/rollTotal() roll 1}}{{#rollTotal() roll 2}}       {{reroll2}}       {{/rollTotal() roll 2}}{{#rollTotal() roll 3}}       {{reroll3}}       {{/rollTotal() roll 3}}{{#rollTotal() roll 4}}       {{reroll4}}       {{/rollTotal() roll 4}}{{#rollTotal() roll 5}}       {{reroll5}}       {{/rollTotal() roll 5}}{{#rollTotal() roll 6}}         etc...          So the final result looks like this: Looking back the primary roll button: {{reroll0=[@{translation_luck}](~@{character_id}|reroll[[@{body}+?{Bonus Dice|0}-@{upset}-@{scared}-@{exhausted}-@{injured}-@{broken}-0]])}} I have trouble understanding some of the complicated syntax here. What does  [@{translation_luck}](~@{character_id}  mean?  Is the "|" used here an "or" operator?  
1605306277
GiGs
Pro
Sheet Author
API Scripter
whamsicore said: {{reroll0=[@{translation_luck}](~@{character_id}|reroll[[@{body}+?{Bonus Dice|0}-@{upset}-@{scared}-@{exhausted}-@{injured}-@{broken}-0]])}} I have trouble understanding some of the complicated syntax here. What does&nbsp; [@{translation_luck}](~@{character_id}&nbsp; mean?&nbsp; Is the "|" used here an "or" operator?&nbsp;&nbsp; For your first question, this is the syntax to print a clickable button into chat. Check out API Buttons:&nbsp; <a href="https://wiki.roll20.net/Macros#Ability_Command_Buttons" rel="nofollow">https://wiki.roll20.net/Macros#Ability_Command_Buttons</a> &nbsp;and&nbsp; <a href="https://wiki.roll20.net/API:Chat#API_Command_Buttons" rel="nofollow">https://wiki.roll20.net/API:Chat#API_Command_Buttons</a> The syntax is this: [Visible Label](macro to be triggered) For your second question, you need to check out how to address attributes in macros, <a href="https://wiki.roll20.net/Macros#Attribute_Macros" rel="nofollow">https://wiki.roll20.net/Macros#Attribute_Macros</a> It looks like this @{character name|attribute name} In Ability Command Buttons, it can look like: (~character name|ability name) The | is being used as a divider. The bit before the | is the character name or id, and the bit after is the Ability to run on that character's sheet.
@GiGs - Thanks that helps a lot. I still have trouble understanding how the reroll "ability" is defined, and the articles don't seem to mention the use of buttons at all. In TFTL, for example, there are multiple &lt;button&gt; tags defined at the beginning of the doc, such as below:&nbsp; &lt;button class="hidden" name="roll_reroll0" type="roll" value="&amp;amp;{template:tftl} {{name=Reroll}} {{character_name=@{character_name}}} {{reroll_dice=0}} {{roll=[[0d6&amp;gt;6]]}}"&gt;&lt;/button&gt; It appears to me that the name of&nbsp; roll_reroll0 is somehow significant. Through the keyword "rerollX", the clickable chat button syntax seems to be turning what is defined in the &lt;button&gt; tag as an "ability"?&nbsp;
1605327327
GiGs
Pro
Sheet Author
API Scripter
The button tags in the html code are not the same thing as API/Ability Buttons, confusingly. All items in html that can be interacted with by players need a name property. Attributes have names in the form name="attr_attribute-name" So if your character has a place to store a strength stat, it will probably look something like &lt;input type="number" name="attr_strength"&gt; in this case, this input is for storing the value of a&nbsp; strength , attribute. As noted above, the&nbsp; attr_ &nbsp;is not part of the name - it is a prefix to tell roll20 what kind of name it is, and the prefix is then disarded. Back to buttons: html buttons can be of two types, action button or roll button, and will have names like name="act_something" name="roll_something" A roll button is a button on the character sheet, which when you click it, will launch a macro into chat. The macro is whatever is inside the value="macro here" part. So this button: &lt;button class="hidden" name="roll_reroll0" is a roll button, named&nbsp; reroll0 .&nbsp; Once you know a roll buttons name, you can access it through a macro, like using the old Ability syntax: &amp;{reroll0} &amp;{Frodo|reroll0} &amp;{selected|reroll0} (Which of the above you use depends on the situation - check the wiki on attribute macros to find more details). or the Ability Button syntax: [Reroll](~reroll0) [Reroll](~Frodo|reroll0) [Reroll](~selected|reroll0) Note that Ability Buttons are things you put inside &nbsp;macros, while html buttons are things which contain macros. Hope that clears some things up.