Difference between revisions of "Dice/MacroContext"

From DiceRoller Documentation
Line 44: Line 44:
 
A MacroContext is created and passed into all [[Dice/MacroCallback|MacroCallbacks]]. The callback must fill out Value and should also fill out Values and ValueType. Failing to fill out Value will result in an error being displayed to the user.
 
A MacroContext is created and passed into all [[Dice/MacroCallback|MacroCallbacks]]. The callback must fill out Value and should also fill out Values and ValueType. Failing to fill out Value will result in an error being displayed to the user.
  
The Param property contains the full string inside of the macro's square brackets. For example, the Param for the macro invocation {{c|[roll:1:critical]}} is the string {{cs|"roll:1:critical"}}. All registered macro callbacks are invoked for every macro, unlike function callbacks which register themselves to a particular function name.
+
The Param property contains the full string inside of the macro's square brackets. For example, the Param for the macro invocation {{c|[roll:1:critical]}} is the string {{cs|"roll:1:critical"}}. The Name property would be "roll" and the Arguments property would be the list "roll", "1", "critical".

Revision as of 23:15, 14 August 2017

Contains the context for a macro and is passed to macro callbacks.

  • Namespace: Dice
  • Assembly: DiceRoller (in DiceRoller.dll)

Inheritance Hierarchy

System.Object

Dice.MacroContext

Syntax

public class MacroContext

Constructors

Name Description
MacroContext(String, RollData) Constructs a new instance of MacroContext.

Properties

Name Description
Arguments Gets the arguments of the macro (including the name), if using the recommended method of separating arguments with colons.
Data Gets roll data for the dice roll.
Name Gets the name of the macro, if using the recommended method of separating arguments with colons.
Param Gets the parameter passed to the macro. The callback is responsible for parsing this into something useful and acting accordingly.
Value Gets or sets the result of the macro.
Values Gets or sets the underlying die results for the macro that should be shown in the overall result.
ValueType Gets or sets the type of value this macro returns.

Remarks

A MacroContext is created and passed into all MacroCallbacks. The callback must fill out Value and should also fill out Values and ValueType. Failing to fill out Value will result in an error being displayed to the user.

The Param property contains the full string inside of the macro's square brackets. For example, the Param for the macro invocation [roll:1:critical] is the string "roll:1:critical". The Name property would be "roll" and the Arguments property would be the list "roll", "1", "critical".