< Dice | BuiltinFunctions
Difference between revisions of "Dice/BuiltinFunctions/If"
From DiceRoller Documentation
(Created page with "{{APIdoc|BuiltinFunction.If Method (FunctionContext)}} Conditionally returns a result based on a comparison. {{ns}} == Syntax == <syntaxhighlight lang="C#"> [DiceFunction("i...") |
(No difference)
|
Latest revision as of 21:52, 27 April 2017
Conditionally returns a result based on a comparison.
- Namespace: Dice
- Assembly: DiceRoller (in DiceRoller.dll)
Syntax
[DiceFunction("if", Scope = FunctionScope.Global)]
public static void If(
FunctionContext context
)
Parameters
- context
- Type: Dice.FunctionContext
- The context of the function call.
Exceptions
| Exception | Condition |
|---|---|
| DiceException (DiceErrorCode.IncorrectArity) | context.Arguments.Count is not exactly 3 or 4. |
| DiceException (DiceErrorCode.IncorrectArgType) | context.Arguments[1] is not a comparison, any of the other arguments is a comparison. |
Remarks
If the short form (3 argument expression, test, then) is used and the comparison fails, a new DieResult with DieType.Literal is returned with the Value 0. This automatically generated DieResult has the DieFlags.Macro flag.