roll.result: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
(New page: The variable ''roll.result'' is used in conjunction with the tooltip roll formatting option, and can be used as the parameter for the tooltip formatting option. ==Examples== <source lan...)
 
No edit summary
 
(8 intermediate revisions by 5 users not shown)
Line 1: Line 1:
The variable ''roll.result'' is used in conjunction with the tooltip roll formatting option, and can be used as the parameter for the tooltip formatting option.  
The special variable {{code|roll.result}} is used within the parameter of the {{roll|tooltip}} roll option.  


==Examples==
===Examples===
 
====Example Mimicking the Default Display====
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[h:AtkBonus=6]
[h:AtkBonus=6]
[h:AbilBonus=4]
[h:AbilBonus=4]
Attack Result: [t(roll.result): 1d20+AtkBonus+AbilBonus]
Attack Result: [t(roll.result): 1d20+AtkBonus+AbilBonus]
</source>
</syntaxhighlight>
 
[[Image:Tooltip-rollresult-example.jpg|frame|right]]
Evaluates {{code|1d20+AtkBonus+AbilBonus}}, assigns that value to {{code|roll.result}}, and then displays the final result with a tooltip containing the value of {{code|roll.result}}.
 
The parameter for the {{roll|tooltip}} roll option is evaluated after the roll itself is evaluated, so that {{code|roll.result}} is available for display.


Evaluates 1d20+AtkBonus+AbilBonus, assigns that value to ''roll.result'', and then displays the final result with a tooltip containing the value of ''roll.result''.
====Example of a Custom Tooltip Based on the {{code|roll.result}}====
To illustrate how the order of evaluation can be useful, consider the following short example:


A screenshot of the output from the example is shown below. Note the information displayed in the tooltip:
<syntaxhighlight lang="mtmacro" line>
[t( if(roll.result > 10, "Hit", "Miss") ): d20]
</syntaxhighlight>
This example will display {{code|Hit}} or {{code|Miss}} depending on the result of the d20 roll, and the tooltip when hovering over either word will be the actual numeric result of the d20 roll.


[[Image:Tooltip-rollresult-example.jpg]]
===See Also===
{{roll|tooltip}}


The parameter for the tooltip option is evaluated after the roll itself is evaluated, so that ''roll.result'' is available for display.
[[Category:Special Variable]]
[[Category:Macro Function]]

Latest revision as of 20:03, 4 July 2023

The special variable roll.result is used within the parameter of the [tooltip:] roll option.

Examples

Example Mimicking the Default Display

[h:AtkBonus=6]
[h:AbilBonus=4]
Attack Result: [t(roll.result): 1d20+AtkBonus+AbilBonus]

Evaluates 1d20+AtkBonus+AbilBonus, assigns that value to roll.result, and then displays the final result with a tooltip containing the value of roll.result.

The parameter for the [tooltip:] roll option is evaluated after the roll itself is evaluated, so that roll.result is available for display.

Example of a Custom Tooltip Based on the roll.result

To illustrate how the order of evaluation can be useful, consider the following short example:

[t( if(roll.result > 10, "Hit", "Miss") ): d20]

This example will display Hit or Miss depending on the result of the d20 roll, and the tooltip when hovering over either word will be the actual numeric result of the d20 roll.

See Also

[tooltip:]