Skip to content

IScriptValueGet

Interface

Class Documentation

Edit documentation

A value getter: an object in a bin script that produces one script value when a block or a condition evaluates it. Getters fill the inputs of script blocks (see IScriptBlock) and conditions (see IScriptCondition). A getter holds a literal value (IntGet, StringGet), reads a script variable (the *TableGet classes, see ScriptTableGet), reads a property of a loaded bin object (the DataObject*Get classes), or builds a new value (ListGet, MapGet). The client evaluates the getter every time the block or condition runs. Nothing caches the result.

Value kinds. Every script value has one of these kinds:

Kind Content Literal getter
Nil No value NilGet
Int 32-bit signed integer IntGet
Bool true or false BoolGet
Float 32-bit float FloatGet
String Text StringGet
Vector3 Three floats VectorGet
Function A script function none
CustomTable A key-value table that scripts create and fill at run time CustomGet, ListGet, MapGet
Entity The id of a game entity EntityReferenceGet, NilEntityGet
EntityTag An entity tag hash EntityTagGet
Path A link to a path object (IPath) PathReferenceGet
Color An RGBA color ColorGet
Int64 64-bit signed integer none
DataObject A loaded bin object DataObjectGet
ResourceKey A resource reference hash 0x7908fe0e
UiElement A UI element UiElementIGet
Unit The id of a unit NilUnitGet
Segment An 8-bit value SegmentGet

Generic and typed reads. A property that takes an IScriptValueGet receives the value together with its kind, and the reader decides what to do with the kind: ComparisonScriptCondition compares two values of any kind, and SetVarInTableBlock stores any value. A property that takes a typed getter interface, such as IFloatGet, IIntGet, IBoolGet, IStringGet, IVectorGet or IEntityGet, asks for that one kind, and any getter that implements the interface fits the property. Every float getter also implements IIntGet, and every int getter also implements IFloatGet. Read as an int, a float is truncated toward zero.

Variables. A script variable is addressed by a table and a variable name. The table is one of the ScriptTable classes, such as InstanceVars or WorldVars. The client resolves the table for the script that is running, so the same getter reads a different instance of the table in each script context. A *TableSet (for example the output of a block) writes a variable and names it by its name string. A *TableGet reads a variable and names it by the hash of the name (FNV-1a of the lowercased name), so both address the same variable. If a *TableGet leaves Table unset, it reads the pass-through parameter table of the running script call. See ScriptTableGet.

Failure. A getter fails when its input does not resolve or does not hold the expected kind. A failing getter raises a script error: the client discards the message, marks the running script as failed, and the block that evaluated the getter skips its effect (see IScriptBlock). A reader can also evaluate a getter with error reporting turned off, test the result and fall back to another input. A failure then raises no error.

Fallbacks. Some table getters return a value of their own when the variable does not give one:

Getter Missing variable Variable of another kind
ScriptTableGet Fails Returns the value with its kind
FloatTableGet, IntTableGet, BoolTableGet, StringTableGet Returns Default if it is set, otherwise fails Converts if it can, otherwise as for a missing variable
FloatOffsetTableGet, IntOffsetTableGet Returns offset Fails
Every other *TableGet Fails Fails, except for the conversions on its page

Referenced by 19 classes · 21 properties