switch (roll option): Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 37: Line 37:
Outputs {{code|used for jabs, so is a puncturing weapon}}.  Notice that the first matching clause was the one that the {{roll|switch}} option found.
Outputs {{code|used for jabs, so is a puncturing weapon}}.  Notice that the first matching clause was the one that the {{roll|switch}} option found.


|also=
{{func|if}},
{{roll|if}}
}}
}}
[[Category:Branching Roll Option]]
[[Category:Branching Roll Option]]

Revision as of 03:22, 5 April 2009

[switch():] Roll Option

* Introduced in version 1.3b46

Chooses among several options and executes code based on the expression.

Usage

[switch(expression):
   case case1: body1;
   case case2: body2;
   default: defaultBody
]

Parameters

  • expression - The regular expression that determines which case is executed. Since this is a regular expression, metacharacters such as * and () will need to have backslashes in front of them if you want to match them literally.
  • case - A potential match for the expression, possesses a corresponding body that is executed if a match is made.
  • default - If the expression finds no matches within the cases, then the defaultBody is executed.

Examples

[h:powerType="at-will"]
[switch(powerType):
case "at-will": "You may use this power as much as you like";
case "encounter": "You may only use this power once per encounter";
case "daily": "You may only use this power once per day"]

Outputs You may use this power as much as you like

[h:powerType=".*sword.*"]
[switch(powerType):
case "flail": "one-handed weapon; two-handed does Str*2 damage";
case "shortsword": "used for jabs, so is a puncturing weapon";
case "longsword": "a slashing weapon"]

Outputs used for jabs, so is a puncturing weapon. Notice that the first matching clause was the one that the [switch():] option found.

See Also

if(), [if():]