Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Template:Plus if pos

Template page
Revision as of 01:09, 7 June 2024 by Taylan (talk | contribs) (Created page with "<includeonly>{{#if: {{{1}}} > 0 | + }}{{trim | {{{1}}} }}</includeonly><noinclude> Adds a plus sign in front of a number if it's positive. Example: <pre> {{plus if positive | 5 }} </pre> Result: {{plus if positive | 5 }} This is useful when calculating some modifier. For example: <pre> {{hidden code| {{#lvardef: dex | 14 }} {{#lvardef: dex_mod | {{plus if positive | {{#expr: floor({{#lvar:dex}} / 2) - 5 }} }} }} }} Your Dexterity Modifier is: {{#lvar:dex_mod}} </...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Adds a plus sign in front of a number if it's positive. Example:

{{plus if positive | 5 }}

Result:

Template:Plus if positive

This is useful when calculating some modifier. For example:

{{hidden code|

{{#lvardef: dex | 14 }}
{{#lvardef: dex_mod | {{plus if positive | {{#expr: floor({{#lvar:dex}} / 2) - 5 }} }} }}

}}

Your Dexterity Modifier is: {{#lvar:dex_mod}}

Result:

Your Dexterity Modifier is: Template:Plus if positive

(Note: Don't be confused by use of Template:Hidden code in the example; it's an unrelated trick for using variable definitions without causing empty paragraphs.)