if (roll option)

From RPTools Wiki
Revision as of 03:17, 5 April 2009 by Verisimilar (talk | contribs) (Added version.)
Jump to navigation Jump to search

[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 to check to determine with roll(true_body or false_body) is executed, if any.
  • true_body - The roll that is executed if the condition evaluates to true(1).
  • false_body - The roll that is executed if the condition evaluates to false(0). If no false_body is given, there is no output if the condition evaluates to false(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
  • != or ne - 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

See Also

if()