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/10/22 18:00] maximemod-management-functions [2022/10/07 11:18] (current) maxime
Line 60: Line 60:
 } }
 myMod:overrideAsset(assetData) myMod:overrideAsset(assetData)
 +</code>
 +
 +----
 +
 +===== registerBehaviorTree =====
 +
 +Registers a new behavior tree (see [[:behavior-trees|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 ====
 +
 +<code lua>
 +myMod:registerBehaviorTree({
 +    Id = "MY_CUSTOM_BEHAVIOR_TREE",
 +    VariableList = {
 +        ...
 +    },
 +    Root = {
 +        ...
 +    }
 +})
 +</code>
 +
 +----
 +
 +===== registerBehaviorTreeNode =====
 +
 +Registers a new behavior tree node (see [[:behavior-trees|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 ====
 +
 +<code lua>
 +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
 +})
 +</code>
 +
 +----
 +
 +===== 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
 +
 +<code lua>
 +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)
 </code> </code>
  
Line 77: Line 166:
 ---- ----
  
-===== registerPrefabComponent =====+===== registerPrefabChild =====
  
-Registers a component to a prefab (see [[:components|Components]] for a complete explanation)+Registers a new child for a prefab
  
-''void **myMod:registerPrefabComponent**(//prefabIdOrPath//, //componentData//)''+''void **myMod:registerPrefabChild**(//parentPrefabIdOrPath//, //id// [, //name//] [, //transform//])''
  
 ^ Name ^ Type ^ Description ^ ^ Name ^ Type ^ Description ^
-| //''prefabIdOrPath''// | ''string'' | the ID or path to the prefab | +| //''parentPrefabIdOrPath''// | ''string'' | the ID or path to the new child's parent 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) |+| //''id''// | ''string'' | the ID of the newly created prefab | 
 +| //''name''// | ''string'' | optionalthe 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 componentData = { +local newChildTransform = { 
-    DataType "COMPONENT_TYPE"+    Position { 0, 0, 1 }
-    ...+    Rotation = { 0, -180, 0 }
 } }
-myMod:registerPrefabComponent(prefabPath, componentData)+ 
 +myMod:registerPrefabChild(prefabPath, "MY_NEW_PREFAB_CHILD_ID", "MyNewChildName", newChildTransform)
 </code> </code>
  
 ---- ----
  
-===== registerBehaviorTree =====+===== registerPrefabComponent =====
  
-Registers a new behavior tree (see [[:behavior-trees|Behavior Trees]] for a complete explanation)+Registers a component to a prefab (see [[:components|Components]] for a complete explanation)
  
-''void **myMod:registerBehaviorTree**(//behaviorTree//)''+''void **myMod:registerPrefabComponent**(//prefabIdOrPath//, //componentData//)''
  
 ^ Name ^ Type ^ Description ^ ^ Name ^ Type ^ Description ^
-| //''behaviorTree''// | ''table'' | the table defining the behavior tree'variables and node tree |+| //''prefabIdOrPath''// | ''string'' | the ID or path to the prefab | 
 +| //''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>
-myMod:registerBehaviorTree(+local componentData = 
-    Id = "MY_CUSTOM_BEHAVIOR_TREE", +    DataType = "COMPONENT_TYPE", 
-    VariableList = { +    ... 
-        ... +} 
-    }, +myMod:registerPrefabComponent(prefabPathcomponentData)
-    Root = { +
-        ... +
-    } +
-})+
 </code> </code>
  
Line 146: Line 235:
 ---- ----
  
-===== configurePrefabFlagList =====+===== registerEnumValue =====
  
-Configure prefab with a list of flags+Registers new dynamic enumeration value
  
-''void **myMod:configurePrefabFlagList**(//prefabPath//, //flagArray//)''+''void **myMod:registerEnumValue**(//enumeration//, //stringValue//)''
  
 ^ Name ^ Type ^ Description ^ ^ Name ^ Type ^ Description ^
-| //''prefabPath''// | ''string'' | the path to the prefab +| //''enumeration''// | ''string'' | the enumeration type 
-| //''flagArray''// | ''table'' | the list of flags to apply on the prefab |+| //''stringValue''// | ''string'' | the new value to add |
  
 ==== Example ==== ==== Example ====
  
 <code lua> <code lua>
-local flagArray = { "BRIDGE", "PLATFORM+myMod:registerEnumValue ("BUILDING_PART_TYPE", "DECORATION")
-myMod:configurePrefabFlagList(prefabPath, flagArray)+
 </code> </code>
  
 ---- ----
  
-===== registerClass =====+===== configurePrefabFlagList =====
  
-Registers new data type, or new type extending an existing one+Configure prefab with list of flags
  
-''void **myMod:registerClass**(//classInfo//)''+''void **myMod:configurePrefabFlagList**(//prefabPath//, //flagArray//)''
  
 ^ Name ^ Type ^ Description ^ ^ Name ^ Type ^ Description ^
-| //''classInfo''// | ''table''table containing all info about the new type |+| //''prefabPath''// | ''string''the path to the prefab | 
 +| //''flagArray''// | ''table'' | the list of flags to apply on the prefab |
  
 ==== Example ==== ==== Example ====
- 
-Definition of a new component type with two properties, and an init function 
  
 <code lua> <code lua>
-local newClassInfo = { +local flagArray = { "BRIDGE", "PLATFORM" } 
-    TypeName = "MY_CUSTOM_COMPONENT", +myMod:configurePrefabFlagList(prefabPath, flagArray)
-    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)+
 </code> </code>
  
 ---- ----
  
-===== registerEnumValue =====+===== overrideTexture =====
  
-Registers a new dynamic enumeration value+Overrides an existing core texture with another one
  
-''void **myMod:registerEnumValue**(//enumeration//, //stringValue//)''+''void **myMod:overrideTexture**(//oldTexturePath//, //newModTexturePath//, //blendMode//)''
  
 ^ Name ^ Type ^ Description ^ ^ Name ^ Type ^ Description ^
-| //''enumeration''// | ''string'' | the enumeration type +| //''oldTexturePath''// | ''string'' | the path to the old core game texture 
-| //''stringValue''// | ''string'' | the new value to add +| //''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 topof the old one|
-==== Example ==== +
- +
-<code lua> +
-myMod:registerEnumValue ("BUILDING_PART_TYPE", "DECORATION") +
-</code>+
  
mod-management-functions.1634940022.txt.gz · Last modified: 2021/10/22 18:00 by maxime

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki