bar.name: Difference between revisions
No edit summary |
mNo edit summary |
||
Line 1: | Line 1: | ||
[[Image:Bar-example.jpg|frame|right|A Two Tone "HP" bar on a token]] | [[Image:Bar-example.jpg|frame|right|A Two Tone "HP" bar on a token]] | ||
The '' | The <code>bar.''name''</code> variable permits the getting and setting of the [[HP_and_Health_Bars|token bar]] value (and the corresponding image displayed on the token) programmatically. Token bars are one, two, or multi-image graphical elements displayed on a token that are used (typically) to visually indicate the status of consumable or expendable items or character traits (such as Hit Points, Ammunition, Health, or the like). | ||
Bars, like [[Token:state|token states]], are configured via the Campaign Properties dialog and are specific to the campaign in which they exist. In the screenshot shown below, the green-on-black line across the top of the token is a token bar. | Bars, like [[Token:state|token states]], are configured via the Campaign Properties dialog and are specific to the campaign in which they exist. In the screenshot shown below, the green-on-black line across the top of the token is a token bar. | ||
Line 10: | Line 10: | ||
</source> | </source> | ||
Sets the value of the token bar named '' | Sets the value of the token bar named ''name'' to the desired value. The bar's ''name'' is set when the bar is created, and may be any name, provided it contains no spaces or special characters except the underscore. ''Value'' must be a number between 0 and 1. When providing a decimal value, include the leading 0 (e.g. enter <code>0.5</code> rather than <code>.5</code>) or your macro will produce an error. | ||
Assigning bar.<i>name</i> to a value will show the bar. If you try to check or use the value of bar.<i>name</i> when the bar is not already visible, your macro will produce an error. | Assigning bar.<i>name</i> to a value will show the bar. If you try to check or use the value of bar.<i>name</i> when the bar is not already visible, your macro will produce an error. |
Revision as of 05:47, 5 November 2019
The bar.name
variable permits the getting and setting of the token bar value (and the corresponding image displayed on the token) programmatically. Token bars are one, two, or multi-image graphical elements displayed on a token that are used (typically) to visually indicate the status of consumable or expendable items or character traits (such as Hit Points, Ammunition, Health, or the like).
Bars, like token states, are configured via the Campaign Properties dialog and are specific to the campaign in which they exist. In the screenshot shown below, the green-on-black line across the top of the token is a token bar.
Usage
[bar.<i>name</i> = value]
Sets the value of the token bar named name to the desired value. The bar's name is set when the bar is created, and may be any name, provided it contains no spaces or special characters except the underscore. Value must be a number between 0 and 1. When providing a decimal value, include the leading 0 (e.g. enter 0.5
rather than .5
) or your macro will produce an error.
Assigning bar.name to a value will show the bar. If you try to check or use the value of bar.name when the bar is not already visible, your macro will produce an error.
While this special variable can be convenient, Using Token Bar Functions instead of token.name can give you more flexibility in your macros.
Examples
[h: HP = HP - DamageTaken]
[h: bar.Health = HP / MaxHP]
Sets the value of bar.Health to the result of HP / MaxHP.
Notes
Two functions, setBar() and getBar() also exist to get and set the value of the token bar.