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
mod-management-functions [2022/09/12 15:42] 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 120: Line 209:
 } }
 myMod:registerPrefabComponent(prefabPath, componentData) myMod:registerPrefabComponent(prefabPath, componentData)
-</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> </code>
  
Line 171: 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.txt · Last modified: 2022/10/07 11:18 by maxime

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki