User Tools

Site Tools


custom-building-function

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
custom-building-function [2022/04/29 20:48] minotoriouscustom-building-function [2022/04/30 19:23] (current) minotorious
Line 27: Line 27:
 ''reloadBuildingFunction'' is called upon save game loading. This function usually serves as a back-call to the ''activateBuilding'' function to ensure any necessities are present and initialised after a reload. ''reloadBuildingFunction'' is called upon save game loading. This function usually serves as a back-call to the ''activateBuilding'' function to ensure any necessities are present and initialised after a reload.
  
-''removeBuildingFunction'' is called when a [[api/building_function|BUILDING_FUNCTION]] is manually unassigned by the player. This function is used to remove components or other elements that should no longer be present once the function is removed from the [[api/building_part|BUILDING_PART]]. **Note:** This is not necesary for non-assignable [[api/building_function|BUILDING_FUNCTION]]s as when a [[api/building_part|BUILDING_PART]] is destroyed everything related to it is also destroyed and their finalisation functions are called automatically.+''removeBuildingFunction'' is called when a [[api/building_function|BUILDING_FUNCTION]] is manually unassigned by the player. This function is used to remove components or other elements that should no longer be present once the function is removed from the [[api/building_part|BUILDING_PART]].
  
 For example below we set up a function that upon activation logs its properties and upon reload executes a back-call to its activation function. For example below we set up a function that upon activation logs its properties and upon reload executes a back-call to its activation function.
Line 35: Line 35:
     mod:log("Property2: " .. tostring(self.Property2))     mod:log("Property2: " .. tostring(self.Property2))
     mod:log("Property3: " .. tostring(self.Property3))     mod:log("Property3: " .. tostring(self.Property3))
 +    
 +    return true
 end end
  
custom-building-function.1651279715.txt.gz · Last modified: 2022/04/29 20:48 by minotorious

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki