if (roll option): Difference between revisions
Jump to navigation
Jump to search
Verisimilar (talk | contribs) m (Added version.) |
Verisimilar (talk | contribs) m (Added references to the code roll option, and added a note about nested parenthesis in the condition.) |
||
Line 13: | Line 13: | ||
</source> | </source> | ||
'''Parameters''' | '''Parameters''' | ||
{{param|condition|The condition to check to determine | {{param|condition|The condition/s to check to determine which roll({{code|true_body}} or {{code|false_body}}) is executed, if any. The condition/s can only contain one level of nested parenthesis.}} | ||
{{param|true_body|The roll that is executed if the {{code|condition}} evaluates to {{true}}.}} | {{param|true_body|The roll that is executed if the {{code|condition}} evaluates to {{true}}. To use complex rolls in the {{code|true_body}}, you must use the {{roll|code}} roll option in conjunction with this roll option.}} | ||
{{param|false_body|The roll that is executed if the {{code|condition}} evaluates to {{false}}. If no {{code|false_body}} is given, there is no output if the {{code|condition}} evaluates to {{false}}.}} | {{param|false_body|The roll that is executed if the {{code|condition}} evaluates to {{false}}. If no {{code|false_body}} is given, there is no output if the {{code|condition}} evaluates to {{false}}. To use complex rolls in the {{code|false_body}}, you must use the {{roll|code}} roll option in conjunction with this roll option.}} | ||
'''Operators'''<br> | '''Operators'''<br> | ||
Operators are used to compare two variables, strings, literal numbers, or function outputs within a {{code|condition}}.<br> | Operators are used to compare two variables, strings, literal numbers, expressions, or function outputs within a {{code|condition}}.<br> | ||
''Conditional Operators:'' | ''Conditional Operators:'' | ||
Line 44: | Line 44: | ||
|also= | |also= | ||
{{func|if}} | {{func|if}}, | ||
{{roll|code}} | |||
}} | }} | ||
[[Category:Branching Roll Option]] | [[Category:Branching Roll Option]] |
Revision as of 20:27, 28 May 2009
[if():] Roll Option
* Introduced in version 1.3b46
Branches the flow of the roll as determined by the condition.
Usage
[if(condition): true_body]
[if(condition): true_body; false_body]
Parameters
condition
- The condition/s to check to determine which roll(true_body
orfalse_body
) is executed, if any. The condition/s can only contain one level of nested parenthesis.true_body
- The roll that is executed if thecondition
evaluates totrue
(1
). To use complex rolls in thetrue_body
, you must use the [code():] roll option in conjunction with this roll option.false_body
- The roll that is executed if thecondition
evaluates tofalse
(0
). If nofalse_body
is given, there is no output if thecondition
evaluates tofalse
(0
). To use complex rolls in thefalse_body
, you must use the [code():] roll option in conjunction with this roll option.
Operators
Operators are used to compare two variables, strings, literal numbers, expressions, or function outputs within a condition
.
Conditional Operators:
>
- Greater than<
- Less than>=
- Greater than or equal to<=
- Less than or equal to==
- Equal to!=
orne
- Not equal
Logical Operators:
&&
- And||
- Or
Boolean Operators:
true
false
It is important to note that the Equal to condition operator must be two equal signs(==
). If you are checking for a text string, place quotes around the text.
Example
Sets the variable newVal
to 12*12
if the variable val
equals 12
.
[h:val=12]
[h,if(val == 12): newVal=12*12]
New Value = [r: newVal]
Returns New Value = 144