< Dice | FunctionContext
FunctionContext.Expression Property
From DiceRoller Documentation
Gets the dice expression this function is attached to, or null if it is a global function.
- Namespace: Dice
- Assembly: DiceRoller (in DiceRoller.dll)
Syntax
public DiceAST Expression { get; internal set; }
Property Value
Type: Dice.AST.DiceAST
The dice expression this function is attached to, or null
if it is a global function.
Remarks
Roll functions will typically look at and perform some transformation on Expression.Value, Expression.ValueType, and Expression.Values (setting the FunctionContext's Value, ValueType, and Values to the modified versions).
Examples
The following example adds one to a roll.
using Dice;
class Sample
{
public static void Main()
{
Roller.DefaultConfig.FunctionRegistry.RegisterFunction("addOne", AddOne, FunctionScope.Roll);
Roller.Roll("4d6dl1.addOne()");
}
public static void AddOne(FunctionContext context)
{
// Expression is the KeepNode representing the "dl1" extra
context.Value = Expression.Value + 1;
}
}