Table of Contents
Mod management functions
All these functions are available on your mod object
dofile
Loads and runs a Lua script
Returns the file's return values
[…] myMod:dofile(scriptPath [, args…])
Name | Type | Description |
---|---|---|
scriptPath | string | the relative path to the file, inside the mod directory |
args | any | optional, variables passed on to the target script |
registerAsset
Deprecated name: register
Register a new game asset
void myMod:registerAsset(assetData)
Name | Type | Description |
---|---|---|
assetData | table | the data defining the new asset. The table must contain at least the asset's type (DataType , see API for the complete list) and its ID (Id ) |
Example
local assetData = { DataType = "ASSET_TYPE", Id = "ASSET_ID", ... } myMod:registerAsset(assetData)
overrideAsset
Deprecated name: override
Override an existing game asset (see Asset Override for a complete explanation)
void myMod:overrideAsset(assetData)
Name | Type | Description |
---|---|---|
assetData | table | the data defining the overridden asset. The table must contain at least the existing asset's type (Id , see Assets for the complete list) |
Example
local assetData = { Id = "ASSET_ID", ... } myMod:overrideAsset(assetData)
registerBehaviorTree
Registers a new behavior tree (see Behavior Trees for a complete explanation)
void myMod:registerBehaviorTree(behaviorTree)
Name | Type | Description |
---|---|---|
behaviorTree | table | the table defining the behavior tree's variables and node tree |
Example
myMod:registerBehaviorTree({ Id = "MY_CUSTOM_BEHAVIOR_TREE", VariableList = { ... }, Root = { ... } })
registerBehaviorTreeNode
Registers a new behavior tree node (see Behavior Trees for a complete explanation)
void myMod:registerBehaviorTreeNode(behaviorTreeNode)
Name | Type | Description |
---|---|---|
behaviorTreeNode | table | the table defining the behavior tree node's variables and functions |
Example
myMod:registerBehaviorTreeNode({ Id = "MY_CUSTOM_BEHAVIOR_TREE_NODE", VariableList = { ... }, Init = function(self, instance) ... end, Update = function(self, level, instance) ... return BEHAVIOR_TREE_NODE_RESULT.TRUE end, Finish = function(self, instance) ... end })
registerClass
Registers a new data type, or a new type extending an existing one
void myMod:registerClass(classInfo)
Name | Type | Description |
---|---|---|
classInfo | table | a table containing all info about the new type |
Example
Definition of a new component type with two properties, and an init function
local newClassInfo = { TypeName = "MY_CUSTOM_COMPONENT", ParentType = "COMPONENT", -- if this field is missing, the new type will be a data type Properties = { { Name = "CurrentRotation", Type = "float", Default = 0.0, Flags = { "SAVE_GAME" } }, { Name = "CurrentPosition", Type = "vec3f" } } } function newClassInfo:init() self.CurrentPosition = self:getOwner():getGlobalPosition() end myMod:registerClass(newClassInfo)
registerAssetId
Assign an asset ID to an asset in the mod's directory
void myMod:registerAssetId(assetPath, assetId [, assetType])
Name | Type | Description |
---|---|---|
assetPath | string | the path to the asset |
assetId | string | the ID to assign to the asset |
assetType | string | optional, type of the asset |
registerPrefabChild
Registers a new child for a prefab
void myMod:registerPrefabChild(parentPrefabIdOrPath, id [, name] [, transform])
Name | Type | Description |
---|---|---|
parentPrefabIdOrPath | string | the ID or path to the new child's parent prefab |
id | string | the ID of the newly created prefab |
name | string | optional, the name of the new prefab, id will be used if no name is provided |
transform | matrix | optional, the transform matrix of the new prefab |
Example
local newChildTransform = { Position = { 0, 0, 1 }, Rotation = { 0, -180, 0 } } myMod:registerPrefabChild(prefabPath, "MY_NEW_PREFAB_CHILD_ID", "MyNewChildName", newChildTransform)
registerPrefabComponent
Registers a component to a prefab (see Components for a complete explanation)
void myMod:registerPrefabComponent(prefabIdOrPath, componentData)
Name | Type | Description |
---|---|---|
prefabIdOrPath | string | the ID or path to the prefab |
componentData | table | the data defining the component. The table must contain at least the component's type (DataType , see API for the complete list) |
Example
local componentData = { DataType = "COMPONENT_TYPE", ... } myMod:registerPrefabComponent(prefabPath, componentData)
registerAssetProcessor
Registers an asset processor to a file (see Building Asset Processor for a complete explanation)
void myMod:registerAssetProcessor(filePath, processorData)
Name | Type | Description |
---|---|---|
filePath | string | the path to the file |
processorData | table | the data defining the asset processor. The table must contain at least the processor's type (DataType , see API for the complete list) |
Example
local processorData= { DataType = "PROCESSOR_TYPE", ... } myMod:registerPrefabComponent(filePath, processorData)
registerEnumValue
Registers a new dynamic enumeration value
void myMod:registerEnumValue(enumeration, stringValue)
Name | Type | Description |
---|---|---|
enumeration | string | the enumeration type |
stringValue | string | the new value to add |
Example
myMod:registerEnumValue ("BUILDING_PART_TYPE", "DECORATION")
configurePrefabFlagList
Configure a prefab with a list of flags
void myMod:configurePrefabFlagList(prefabPath, flagArray)
Name | Type | Description |
---|---|---|
prefabPath | string | the path to the prefab |
flagArray | table | the list of flags to apply on the prefab |
Example
local flagArray = { "BRIDGE", "PLATFORM" } myMod:configurePrefabFlagList(prefabPath, flagArray)
overrideTexture
Overrides an existing core texture with another one
void myMod:overrideTexture(oldTexturePath, newModTexturePath, blendMode)
Name | Type | Description |
---|---|---|
oldTexturePath | string | the path to the old core game texture |
newModTexturePath | string | the path to the new mod texture |
blendMode | string | an option on how the new texture is used. Can be either REPLACE (to fully replace the old texture with the new one) or ALPHA_BLEND (to draw the new texture “on top” of the old one) |