StructType¶
Overview¶
A StructType config provides a collection of data values, accessible by ParamTypes.
Each struct contains data where each separate input key is a ParamType and the corresponding output value is a ValueType matching that of the given param.
Input keys are unique within the config - the same ParamType cannot exist in the same struct multiple times.
These config types can be found within the config.Struct table:
config.Struct.BOSS_INSTANCE_STALKER_BOSS
config.Struct["BOSS_INSTANCE_STALKER_BOSS"]
config.Struct.FromID(922) -- config.Struct.BOSS_INSTANCE_STALKER_BOSS
Info
An StructType is a Proxy usertype, which means it is safe to copy and store in your scripts.
It cannot, however, be used with any persistent storage.
Information available within an StructType includes:
- Param data stored
Examples¶
-- Access a StructType config directly by using its name
local bossCfg = config.Struct.BOSS_INSTANCE_STALKER_BOSS
-- or by ID lookup
local bossCfg = config.Struct.FromID(id.Struct.BOSS_INSTANCE_STALKER_BOSS)
-- Get values for some params contained in the struct
local bossName = config.Struct.BOSS_INSTANCE_STALKER_BOSS:GetParamValue(config.Param.BOSS_INSTANCE_BOSS_NAME) -- "Flesh-hatcher Mhekarnahz"
local bossNPC = config.Struct.BOSS_INSTANCE_STALKER_BOSS:GetParamValue(config.Param.BOSS_INSTANCE_BOSS_NPC) -- config.NPC.STALKER_BOSS
-- Iterate all data values
-- Values data is returned as an array of pairs, i.e. [ [ParamType, dataValue], [ParamType, dataValue], ... ]
local allParams = config.Struct.BOSS_INSTANCE_STALKER_BOSS.paramValues
for _,keyValuePair in ipairs(allParams) do
local paramType = keyValuePair[1] -- config.Param.BOSS_INSTANCE_BOSS_NPC
local paramValue = keyValuePair[2] -- config.NPC.STALKER_BOSS
end
Constructors¶
Info
This usertype has no constructor, and you cannot create your own.
Methods¶
GetParamValue¶
Returns the corresponding output value for the given input ParamType.
| Parameter | Type | Description |
|---|---|---|
| param | ParamType | The input param value. |
| Returns | Description |
|---|---|
| ? | The corresponding output value.Returns param.defaultValue if the param is not found in the data structure. |
Example
-- Get a boss name
local name = config.Struct.BOSS_INSTANCE_STALKER_BOSS:GetParamValue(config.Param.BOSS_INSTANCE_BOSS_NAME) -- "Flesh-hatcher Mhekarnahz"
-- And another few boss names in different structs using the same param
local name2 = config.Struct.BOSS_INSTANCE_DINO_BOSS:GetParamValue(config.Param.BOSS_INSTANCE_BOSS_NAME) -- "Raksha"
local name3 = config.Struct.BOSS_INSTANCE_GWD2_ZAROS:GetParamValue(config.Param.BOSS_INSTANCE_BOSS_NAME) -- "Vindicta & Gorvek"
HasParam¶
Returns whether this config contains output data for the given input ParamType.
| Parameter | Type | Description |
|---|---|---|
| param | ParamType | The input param value. |
| Returns | Description |
|---|---|
| Boolean | Whether a corresponding value exists in this config for ParamType. |
Example
Properties¶
Info
All properties are read-only.
| Name | Type | Description |
|---|---|---|
| id | Integer | The ID of this config type. |
| configName | String | The name of this config, i.e. "BOSS_INSTANCE_STALKER_BOSS". |
| typeName | String | The type of this config. Will always be "Struct". |
| params | Returns a list of all the ParamTypes stored in this config. |