User Tools

Site Tools


mod-management-functions

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
mod-management-functions [2021/11/12 13:33] maximemod-management-functions [2022/10/07 11:18] (current) maxime
Line 64: Line 64:
 ---- ----
  
-===== registerAssetId =====+===== registerBehaviorTree =====
  
-Assign an asset ID to an asset in the mod's directory+Registers a new behavior tree (see [[:behavior-trees|Behavior Trees]] for a complete explanation)
  
-''void **myMod:registerAssetId**(//assetPath//, //assetId// [, //assetType//])''+''void **myMod:registerBehaviorTree**(//behaviorTree//)''
  
 ^ Name ^ Type ^ Description ^ ^ Name ^ Type ^ Description ^
-| //''assetPath''// | ''string'' | the path to the asset | +| //''behaviorTree''// | ''table'' | the table defining the behavior tree's variables and node tree 
-| //''assetId''// | ''string'' | the ID to assign to the asset + 
-//''assetType''// | ''string'' | optional, type of the asset |+==== Example ==== 
 + 
 +<code lua> 
 +myMod:registerBehaviorTree({ 
 +    Id = "MY_CUSTOM_BEHAVIOR_TREE", 
 +    VariableList = { 
 +        ... 
 +    }, 
 +    Root = { 
 +        ... 
 +    } 
 +}) 
 +</code>
  
 ---- ----
  
-===== registerPrefabComponent =====+===== registerBehaviorTreeNode =====
  
-Registers a component to a prefab (see [[:components|Components]] for a complete explanation)+Registers a new behavior tree node (see [[:behavior-trees|Behavior Trees]] for a complete explanation)
  
-''void **myMod:registerPrefabComponent**(//prefabIdOrPath//, //componentData//)''+''void **myMod:registerBehaviorTreeNode**(//behaviorTreeNode//)''
  
 ^ Name ^ Type ^ Description ^ ^ Name ^ Type ^ Description ^
-| //''prefabIdOrPath''// | ''string'' | the ID or path to the prefab | +| //''behaviorTreeNode''// | ''table'' | the table defining the behavior tree node'variables and functions |
-| //''componentData''// | ''table'' | the data defining the component. The table must contain at least the component'type (''DataType'', see [[api#component_classes|API]] for the complete list) |+
  
 ==== Example ==== ==== Example ====
  
 <code lua> <code lua>
-local componentData = +myMod:registerBehaviorTreeNode(
-    DataType = "COMPONENT_TYPE", +    Id = "MY_CUSTOM_BEHAVIOR_TREE_NODE", 
-    ... +    VariableList = { 
-+        ... 
-myMod:registerPrefabComponent(prefabPathcomponentData)+    }, 
 +    Init = function(selfinstance) 
 +        ... 
 +    end, 
 +    Update = function(self, level, instance) 
 +        ... 
 +        return BEHAVIOR_TREE_NODE_RESULT.TRUE 
 +    end, 
 +    Finish = function(self, instance) 
 +       ... 
 +    end 
 +})
 </code> </code>
  
 ---- ----
  
-===== registerBehaviorTree =====+===== registerClass =====
  
-Registers a new behavior tree (see [[:behavior-trees|Behavior Trees]] for complete explanation)+Registers a new data type, or new type extending an existing one
  
-''void **myMod:registerBehaviorTree**(//behaviorTree//)''+''void **myMod:registerClass**(//classInfo//)''
  
 ^ Name ^ Type ^ Description ^ ^ Name ^ Type ^ Description ^
-| //''behaviorTree''// | ''table''the table defining the behavior tree's variables and node tree |+| //''classInfo''// | ''table''table containing all info about the new type |
  
 ==== Example ==== ==== Example ====
 +
 +Definition of a new component type with two properties, and an init function
  
 <code lua> <code lua>
-myMod:registerBehaviorTree(+local newClassInfo = 
-    Id = "MY_CUSTOM_BEHAVIOR_TREE", +    TypeName = "MY_CUSTOM_COMPONENT", 
-    VariableList = { +    ParentType = "COMPONENT", -- if this field is missing, the new type will be a data type 
-        ... +    Properties = { 
-    }, +        { Name = "CurrentRotation", Type = "float", Default = 0.0Flags = { "SAVE_GAME" } }, 
-    Root = { +        { Name = "CurrentPosition", Type = "vec3f" }
-        ...+
     }     }
-})+} 
 + 
 +function newClassInfo:init() 
 +    self.CurrentPosition = self:getOwner():getGlobalPosition() 
 +end 
 + 
 +myMod:registerClass(newClassInfo)
 </code> </code>
  
 ---- ----
  
-===== registerAssetProcessor =====+===== registerAssetId =====
  
-Registers an asset processor to a file (see [[:building-asset-processor|Building Asset Processor]] for a complete explanation)+Assign an asset ID to an asset in the mod's directory
  
-''void **myMod:registerAssetProcessor**(//filePath//, //processorData//)''+''void **myMod:registerAssetId**(//assetPath//, //assetId// [, //assetType//])''
  
 ^ Name ^ Type ^ Description ^ ^ Name ^ Type ^ Description ^
-| //''filePath''// | ''string'' | the path to the file +| //''assetPath''// | ''string'' | the path to the asset 
-| //''processorData''// | ''table'' | the data defining the asset processor. The table must contain at least the processor's type (''DataType'', see [[api#asset_processor_classes|API]] for the complete list) |+| //''assetId''// | ''string'' | the ID to assign to the asset 
 +| //''assetType''// | ''string'' | optionaltype 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 ==== ==== Example ====
  
 <code lua> <code lua>
-local processorData= { +local newChildTransform = { 
-    DataType "PROCESSOR_TYPE"+    Position { 0, 0, 1 }
-    ...+    Rotation = { 0, -180, 0 }
 } }
-myMod:registerPrefabComponent(filePathprocessorData)+ 
 +myMod:registerPrefabChild(prefabPath"MY_NEW_PREFAB_CHILD_ID", "MyNewChildName", newChildTransform)
 </code> </code>
  
 ---- ----
  
-===== configurePrefabFlagList =====+===== registerPrefabComponent =====
  
-Configure a prefab with list of flags+Registers a component to a prefab (see [[:components|Components]] for complete explanation)
  
-''void **myMod:configurePrefabFlagList**(//prefabPath//, //flagArray//)''+''void **myMod:registerPrefabComponent**(//prefabIdOrPath//, //componentData//)''
  
 ^ Name ^ Type ^ Description ^ ^ Name ^ Type ^ Description ^
-| //''prefabPath''// | ''string'' | the path to the prefab | +| //''prefabIdOrPath''// | ''string'' | the ID or path to the prefab | 
-| //''flagArray''// | ''table'' | the list of flags to apply on the prefab |+| //''componentData''// | ''table'' | the data defining the component. The table must contain at least the component's type (''DataType'', see [[api#component_classes|API]] for the complete list) |
  
 ==== Example ==== ==== Example ====
  
 <code lua> <code lua>
-local flagArray = { "BRIDGE", "PLATFORM" +local componentData = { 
-myMod:configurePrefabFlagList(prefabPath, flagArray)+    DataType = "COMPONENT_TYPE", 
 +    ... 
 +
 +myMod:registerPrefabComponent(prefabPath, componentData)
 </code> </code>
  
 ---- ----
  
-===== registerClass =====+===== registerAssetProcessor =====
  
-Registers a new data type, or new type extending an existing one+Registers an asset processor to file (see [[:building-asset-processor|Building Asset Processor]] for complete explanation)
  
-''void **myMod:registerClass**(//classInfo//)''+''void **myMod:registerAssetProcessor**(//filePath//, //processorData//)''
  
 ^ Name ^ Type ^ Description ^ ^ Name ^ Type ^ Description ^
-| //''classInfo''// | ''table''table containing all info about the new type |+| //''filePath''// | ''string'' | the path to the file | 
 +| //''processorData''// | ''table''the data defining the asset processor. The table must contain at least the processor'type (''DataType'', see [[api#asset_processor_classes|API]] for the complete list) |
  
 ==== Example ==== ==== Example ====
- 
-Definition of a new component type with two properties, and an init function 
  
 <code lua> <code lua>
-local newClassInfo = { +local processorData= { 
-    TypeName = "MY_CUSTOM_COMPONENT", +    DataType = "PROCESSOR_TYPE", 
-    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"+
-    }+
 } }
- +myMod:registerPrefabComponent(filePath, processorData)
-function newClassInfo:init() +
-    self.CurrentPosition = self:getOwner():getGlobalPosition() +
-end +
- +
-myMod:registerClass(newClassInfo)+
 </code> </code>
  
Line 215: Line 253:
 ---- ----
  
-===== createData =====+===== configurePrefabFlagList =====
  
-Creates new instance of data type+Configure prefab with list of flags
  
-''void **myMod:createData**(//instanceData//)''+''void **myMod:configurePrefabFlagList**(//prefabPath//, //flagArray//)''
  
 ^ Name ^ Type ^ Description ^ ^ Name ^ Type ^ Description ^
-| //''instanceData''// | ''table'' or ''nil'' | the data defining the new instance. If not ''nil'', the table must contain at least the instance's type (''DataType'', see [[api|API]] for the complete list|+| //''prefabPath''// | ''string'' | the path to the prefab | 
 +| //''flagArray''// | ''table'' | the list of flags to apply on the prefab |
  
 ==== Example ==== ==== Example ====
  
 <code lua> <code lua>
-local instanceData = { +local flagArray = { "BRIDGE", "PLATFORM" 
-    DataType = "DATA_TYPE", +myMod:configurePrefabFlagList(prefabPath, flagArray)
-    ... +
-+
-myMod:createData(instanceData )+
 </code> </code>
 +
 +----
 +
 +===== 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) |
  
mod-management-functions.1636742009.txt.gz · Last modified: 2021/11/12 13:33 by maxime

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki