< Dice‎ | BuiltinFunctions
Revision as of 21:52, 27 April 2017 by Skizzerz (talk | contribs) (Created page with "{{APIdoc|BuiltinFunction.If Method (FunctionContext)}} Conditionally returns a result based on a comparison. {{ns}} == Syntax == <syntaxhighlight lang="C#"> [DiceFunction("i...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

BuiltinFunction.If Method (FunctionContext)

From DiceRoller Documentation

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.