< Dice
Difference between revisions of "Dice/MacroCallback"
From DiceRoller Documentation
Line 17: | Line 17: | ||
== Remarks == | == Remarks == | ||
− | The MacroCallback delegate is used alongside [[Dice/RollerConfig/ExecuteMacro|RollerConfig.ExecuteMacro]]. The delegate can gain insight into the context of the macro call by examining the passed-in ''context'' object, and it must also modify the ''context'' object's Value. If no delegate in the chain modifies the context's Value | + | The MacroCallback delegate is used alongside [[Dice/RollerConfig/ExecuteMacro|RollerConfig.ExecuteMacro]]. The delegate can gain insight into the context of the macro call by examining the passed-in ''context'' object, and it must also modify the ''context'' object's Value. If no delegate in the chain modifies the context's Value, a [[Dice/DiceException|DiceException]] is thrown with DiceErrorCode.InvalidMacro. |
− | If the | + | If the context's Values is left empty, a new Literal die will be added equivalent to the context's Value. It will be marked with [[Dice/DieFlags|DieFlags.Macro]]. It is recommended that any DieResults added to Values by a macro are marked with DieFlags.Macro, but this is not a requirement. |
Latest revision as of 20:40, 12 April 2017
Encapsulates a method which executes macro logic.
- Namespace: Dice
- Assembly: DiceRoller (in DiceRoller.dll)
Syntax
public delegate void MacroCallback(
MacroContext context
)
Parameters
- context
- Type: Dice.MacroContext
- Macro context, to be filled in by the delegate.
Remarks
The MacroCallback delegate is used alongside RollerConfig.ExecuteMacro. The delegate can gain insight into the context of the macro call by examining the passed-in context object, and it must also modify the context object's Value. If no delegate in the chain modifies the context's Value, a DiceException is thrown with DiceErrorCode.InvalidMacro.
If the context's Values is left empty, a new Literal die will be added equivalent to the context's Value. It will be marked with DieFlags.Macro. It is recommended that any DieResults added to Values by a macro are marked with DieFlags.Macro, but this is not a requirement.