custom-building-function
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
custom-building-function [2022/03/30 10:33] – created minotorious | custom-building-function [2022/04/30 19:23] (current) – minotorious | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | [[api/ | + | [[api/ |
For reference all available [[api/ | For reference all available [[api/ | ||
- | ===== Creating & Using a Custom | + | ===== Creating & Using a Custom |
- | ==== Step 1: Defining | + | ==== Step 1: Defining |
To create a custom [[api/ | To create a custom [[api/ | ||
- | Here you decide what properties your custom [[api/ | + | Here you decide what properties your custom [[api/ |
<code lua> | <code lua> | ||
local MY_BUILDING_FUNCTION = { | local MY_BUILDING_FUNCTION = { | ||
Line 18: | Line 18: | ||
} | } | ||
} | } | ||
+ | </ | ||
+ | Now that the base [[api/ | ||
+ | All [[api/ | ||
+ | |||
+ | '' | ||
+ | |||
+ | '' | ||
+ | |||
+ | '' | ||
+ | |||
+ | 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. | ||
+ | <code lua> | ||
+ | function MY_BUILDING_FUNCTION: | ||
+ | mod: | ||
+ | mod: | ||
+ | mod: | ||
+ | | ||
+ | return true | ||
+ | end | ||
+ | |||
+ | function MY_BUILDING_FUNCTION: | ||
+ | self: | ||
+ | end | ||
+ | </ | ||
+ | And finally we register our custom [[api/ | ||
+ | <code lua> | ||
mod: | mod: | ||
</ | </ | ||
Line 41: | Line 67: | ||
In case you omit any properties you don't yet need to explicitly set they will use their default values. As we have done with '' | In case you omit any properties you don't yet need to explicitly set they will use their default values. As we have done with '' | ||
- | ==== Step 3: Using an Instance of an BUILDING_FUNCTION Class ==== | + | ==== Step 3: Using an Instance of a BUILDING_FUNCTION Class ==== |
When you want to use your new [[api/ | When you want to use your new [[api/ | ||
<code lua> | <code lua> |
custom-building-function.txt · Last modified: 2022/04/30 19:23 by minotorious