if (roll option): Difference between revisions
Jump to navigation
Jump to search
Verisimilar (talk | contribs) (Redirect pending split of article.) |
Verisimilar (talk | contribs) m (Initial copy-over.) |
||
Line 1: | Line 1: | ||
{{RollOption | |||
[[ | |name=if | ||
|description= | |||
Branches the flow of the roll as determined by the condition. | |||
|usage= | |||
<source lang="mtmacro" line> | |||
[if(condition): true_body] | |||
</source> | |||
<source lang="mtmacro" line> | |||
[if(condition): true_body; false_body] | |||
</source> | |||
'''Parameters''' | |||
{{param|condition|The condition to check to determine with roll({{code|true_body}} or {{code|false_body}}) is executed, if any.}} | |||
{{param|true_body|The roll that is executed if the {{code|condition}} evaluates to {{true}}.}} | |||
{{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}}.}} | |||
'''Operators'''<br> | |||
Operators are used to compare two variables, strings, literal numbers, or function outputs within a {{code|condition}}.<br> | |||
''Conditional Operators:'' | |||
* {{code|>}} - Greater than | |||
* {{code|<}} - Less than | |||
* {{code|>{{=}}}} - Greater than or equal to | |||
* {{code|<{{=}}}} - Less than or equal to | |||
* {{code|{{=}}{{=}}}} - Equal to | |||
* {{code|!{{=}}}} or {{code|ne}} - Not equal | |||
''Logical Operators:'' | |||
* {{code|&&}} - And | |||
* {{code|{{!}}{{!}}}} - Or | |||
''Boolean Operators:'' | |||
* {{code|true}} | |||
* {{code|false}} | |||
It is important to note that the ''Equal to'' condition operator must be two equal signs({{code|{{=}}{{=}}}}). If you are checking for a text string, place quotes around the text. | |||
|example= | |||
Sets the variable {{code|newVal}} to {{code|12*12}} if the variable {{code|val}} equals {{code|12}}. | |||
<source lang="mtmacro" line> | |||
[h:val=12] | |||
[h,if(val == 12): newVal=12*12] | |||
New Value = [r: newVal] | |||
</source> | |||
Returns {{code|New Value {{=}} 144}} | |||
|also= | |||
{{func|if}} | |||
}} | |||
[[Category:Branching Roll Option]] | [[Category:Branching Roll Option]] |
Revision as of 03:04, 5 April 2009
[if():] Roll Option
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 to check to determine with roll(true_body
orfalse_body
) is executed, if any.true_body
- The roll that is executed if thecondition
evaluates totrue
(1
).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
).
Operators
Operators are used to compare two variables, strings, literal numbers, 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