Drag[en]gine Script Module DragonScript  1.23
Dragengine.Utils.TRRVariable Class Reference

Rule for resolving variables in text. More...

Inheritance diagram for Dragengine.Utils.TRRVariable:
Dragengine.Utils.TagResolverRule

Public Member Functions

void forEach (Block ablock)
 Visit variables with block. More...
 
String getAt (String variable, String defaultValue)
 Value of variable or default value if absent. More...
 
int getCount ()
 Count of variables. More...
 
Array getKeys ()
 List of all variables names. More...
 
byte getSeparatorDefaultValue ()
 Separate character between variable name and default value. More...
 
bool has (String variable)
 Variable is present. More...
 
TRRVariable new ()
 Create resolve variable rule with empty variable table. More...
 
TRRVariable new (TRRVariable rule)
 Create copy of resolve variable rule. More...
 
void remove (String variable)
 Remove value if present. More...
 
void removeAll ()
 Remove all variables. More...
 
String resolveTag (String parameters, Object context)
 Resolve tag returning text to output instead of the tag. More...
 
void setAt (String variable, String value)
 Set value of variable. More...
 
void setSeparatorDefaultValue (byte separator)
 Set separate character between variable name and default value. More...
 

Public Attributes

byte pSeparatorDefaultValue
 
Dictionary pVariables
 

Detailed Description

Rule for resolving variables in text.

Supports tags of the form {action:variable name[,default value]}. "action" is the action named used while adding the rule. A typical value to use for action is "var" or "variable". The "variable name" parameter is the name of the variable to look up in the variable table. If the variable is present the value stored in the variable table is returned as resolved text. If the variable is absent the parameter "default value" is returned as resolved text. If the parameter "default value" is absent an empty string is returned as text. The "," separator between variable name and default value can be changed to any other character. This is useful if you need "," for your variable names.

The variable name can use any character except the default value separator (default ",") and "{" or "}" which are used as tag boundaries. This class is not going to check the names of variables added to the list to follow this rules. If you do not follow this rule the variables will be ignored.

The typical way of using this rule is to store it aside in the scripts using the TagResolver. Before processing text set the variables you want to be used to this rule.

Member Function Documentation

◆ forEach()

void Dragengine.Utils.TRRVariable.forEach ( Block  ablock)

Visit variables with block.

Block receives as first argument String name and as second argument String value.

◆ getAt()

String Dragengine.Utils.TRRVariable.getAt ( String  variable,
String  defaultValue 
)

Value of variable or default value if absent.

◆ getCount()

int Dragengine.Utils.TRRVariable.getCount ( )

Count of variables.

◆ getKeys()

Array Dragengine.Utils.TRRVariable.getKeys ( )

List of all variables names.

Version
1.19

Returns Array with String for each key.

◆ getSeparatorDefaultValue()

byte Dragengine.Utils.TRRVariable.getSeparatorDefaultValue ( )

Separate character between variable name and default value.

◆ has()

bool Dragengine.Utils.TRRVariable.has ( String  variable)

Variable is present.

◆ new() [1/2]

TRRVariable Dragengine.Utils.TRRVariable.new ( )

Create resolve variable rule with empty variable table.

◆ new() [2/2]

TRRVariable Dragengine.Utils.TRRVariable.new ( TRRVariable  rule)

Create copy of resolve variable rule.

◆ remove()

void Dragengine.Utils.TRRVariable.remove ( String  variable)

Remove value if present.

◆ removeAll()

void Dragengine.Utils.TRRVariable.removeAll ( )

Remove all variables.

◆ resolveTag()

String Dragengine.Utils.TRRVariable.resolveTag ( String  parameters,
Object  context 
)

Resolve tag returning text to output instead of the tag.

Parameters
parametersParameters inside tag.
contextObject in the context of which the resolving is done. Context is not used.

Implements Dragengine.Utils.TagResolverRule.

◆ setAt()

void Dragengine.Utils.TRRVariable.setAt ( String  variable,
String  value 
)

Set value of variable.

◆ setSeparatorDefaultValue()

void Dragengine.Utils.TRRVariable.setSeparatorDefaultValue ( byte  separator)

Set separate character between variable name and default value.

Member Data Documentation

◆ pSeparatorDefaultValue

byte Dragengine.Utils.TRRVariable.pSeparatorDefaultValue

◆ pVariables

Dictionary Dragengine.Utils.TRRVariable.pVariables

The documentation for this class was generated from the following file: