User Tools

Site Tools


mod-management-functions

Differences

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

Link to this comparison view

Next revision
Previous revision
Next revisionBoth sides next revision
mod-management-functions [2020/05/06 16:49] – created maximemod-management-functions [2020/07/17 14:35] maxime
Line 1: Line 1:
 ====== Mod management functions ====== ====== Mod management functions ======
 +
 +All these functions are available on your mod object
  
 ===== dofile ===== ===== dofile =====
Line 19: Line 21:
 Register a new game asset Register a new game asset
  
-''void **myMod:register**(//assetData//])''+''void **myMod:register**(//assetData//)''
  
 ^ Name ^ Type ^ Description ^ ^ Name ^ Type ^ Description ^
Line 41: Line 43:
 Override an existing game asset (see [[:asset-override|Asset Override]] for a complete explanation) Override an existing game asset (see [[:asset-override|Asset Override]] for a complete explanation)
  
-''void **myMod:override**(//assetData//])''+''void **myMod:override**(//assetData//)''
  
 ^ Name ^ Type ^ Description ^ ^ Name ^ Type ^ Description ^
Line 62: Line 64:
 Assign an asset ID to an asset in the mod's directory Assign an asset ID to an asset in the mod's directory
  
-''void **myMod:registerAssetId**(//assetPath//, //assetId//])''+''void **myMod:registerAssetId**(//assetPath//, //assetId//)''
  
 ^ Name ^ Type ^ Description ^ ^ Name ^ Type ^ Description ^
Line 74: Line 76:
 Registers a component to a prefab (see [[:components|Components]] for a complete explanation) Registers a component to a prefab (see [[:components|Components]] for a complete explanation)
  
-''void **myMod:registerPrefabComponent**(//prefabPath//, //componentData//])''+''void **myMod:registerPrefabComponent**(//prefabPath//, //componentData//)''
  
 ^ Name ^ Type ^ Description ^ ^ Name ^ Type ^ Description ^
Line 88: Line 90:
 } }
 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 96: Line 123:
 Registers an asset processor to a file (see [[:building-asset-processor|Building Asset Processor]] for a complete explanation) Registers an asset processor to a file (see [[:building-asset-processor|Building Asset Processor]] for a complete explanation)
  
-''void **myMod:registerAssetProcessor**(//filePath//, //processorData//])''+''void **myMod:registerAssetProcessor**(//filePath//, //processorData//)''
  
 ^ Name ^ Type ^ Description ^ ^ Name ^ Type ^ Description ^
Line 118: Line 145:
 Configure a prefab with a list of flags Configure a prefab with a list of flags
  
-''void **myMod:configurePrefabFlagList**(//prefabPath//, //flagArray//])''+''void **myMod:configurePrefabFlagList**(//prefabPath//, //flagArray//)''
  
 ^ Name ^ Type ^ Description ^ ^ Name ^ Type ^ Description ^
Line 127: Line 154:
  
 <code lua> <code lua>
-local flagArray = { "BRIDGE", "PLATEFORM" }+local flagArray = { "BRIDGE", "PLATFORM" }
 myMod:configurePrefabFlagList(prefabPath, flagArray) myMod:configurePrefabFlagList(prefabPath, flagArray)
 +</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>
 +
 +----
 +
 +===== 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 ====
 +
 +<code lua>
 +myMod:registerEnumValue ("BUILDING_PART_TYPE", "DECORATION")
 </code> </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