custom-asset
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
custom-asset [2022/03/29 20:52] – created minotorious | custom-asset [2022/03/30 10:16] (current) – minotorious | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ASSET classes are the basic registerable types in Foundation. | + | [[assets|ASSET]] classes are the basic registerable types in Foundation. |
- | For reference all available | + | For reference all available |
===== Creating & Using a Custom ASSET Object ===== | ===== Creating & Using a Custom ASSET Object ===== | ||
==== Step 1: Defining an ASSET Object using a Lua Table ==== | ==== Step 1: Defining an ASSET Object using a Lua Table ==== | ||
- | To create a custom ASSET object we will need to make use of the '' | + | To create a custom |
- | Here you decide what properties your custom ASSET object will contain. | + | Here you decide what properties your custom |
<code lua> | <code lua> | ||
local MY_ASSET_OBJECT = { | local MY_ASSET_OBJECT = { | ||
- | TypeName = " | + | TypeName = " |
DataType = " | DataType = " | ||
Properties = { | Properties = { | ||
Line 21: | Line 21: | ||
mod: | mod: | ||
</ | </ | ||
- | Note that ASSETs | + | Note that [[assets|ASSET]]s |
- | Also remember that you can define properties based on the basic [[data-types|data types]] (i.e. string, integer, float, etc.) or based on any of the existing DATA or ASSET objects, as well as '' | + | Also remember that you can define properties based on the basic [[data-types|data types]] (i.e. string, integer, float, etc.) or based on any of the existing |
==== Step 2: Registering an Instance of an ASSET Object ==== | ==== Step 2: Registering an Instance of an ASSET Object ==== | ||
Note: This also aplies to using vanilla ASSET objects! | Note: This also aplies to using vanilla ASSET objects! | ||
- | In your mod's lua code you when you want to register an instance of your new ASSET object you will have to use the '' | + | In your mod's lua code you when you want to register an instance of your new [[assets|ASSET]] object you will have to use the '' |
<code lua> | <code lua> | ||
mod: | mod: | ||
- | DataType = " | + | DataType = " |
Id = " | Id = " | ||
Property1 = " | Property1 = " | ||
Line 37: | Line 37: | ||
}) | }) | ||
</ | </ | ||
- | Remember, each unique ASSET instance requires an Id that identifies it from other ASSETs | + | Remember, each unique |
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 '' | ||
Line 44: | Line 44: | ||
When you want to use your new ASSET instance be it in a [[api/ | When you want to use your new ASSET instance be it in a [[api/ | ||
- | For example here we are using our custom ASSET instance as the default value in a [[api/ | + | For example here we are using our custom |
<code lua> | <code lua> | ||
local COMP_EXAMPLE = { | local COMP_EXAMPLE = { |
custom-asset.1648601522.txt.gz · Last modified: 2022/03/29 20:52 by minotorious