User Tools

Site Tools


custom-asset

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-asset [2022/03/29 20:53] minotoriouscustom-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 ASSET classes can be found in [[api#assets_classes|this]] section of the API.+For reference all available [[assets|ASSET]] classes can be found in [[api#assets_classes|this]] section of the API.
  
 ===== Creating & Using a Custom ASSET Object ===== ===== Creating & Using a Custom ASSET Object =====
Line 10: Line 10:
 <code lua> <code lua>
 local MY_ASSET_OBJECT = { local MY_ASSET_OBJECT = {
-    TypeName = "MY_ASSET_OBJECT ",+    TypeName = "MY_ASSET_OBJECT",
     DataType = "ASSET",     DataType = "ASSET",
     Properties = {     Properties = {
Line 21: Line 21:
 mod:registerClass(MY_ASSET_OBJECT) mod:registerClass(MY_ASSET_OBJECT)
 </code> </code>
-Note that ASSETs unlike DATA do not need the ''SAVE_GAME'' flag as their properties are read from their registration on load!+Note that [[assets|ASSET]]s unlike [[api#data_classes|DATA]] do not need the ''SAVE_GAME'' flag as their properties are read from their registration on load!
  
-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 ''list''s therof!+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 [[api#data_classes|DATA]] or [[assets|ASSET]] objects, as well as ''list''s therof!
  
 ==== 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 ''mod:registerAsset(AssetTable)'' method as follows.+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 ''mod:registerAsset(AssetTable)'' method as follows.
 <code lua> <code lua>
 mod:registerAsset({ mod:registerAsset({
-    DataType = "MY_ASSET_OBJECT ",+    DataType = "MY_ASSET_OBJECT",
     Id = "MY_ASSET_OBJECT_INSTANCE",     Id = "MY_ASSET_OBJECT_INSTANCE",
     Property1 = "SomeOtherString",     Property1 = "SomeOtherString",
Line 44: Line 44:
 When you want to use your new ASSET instance be it in a [[api/component|COMPONENT]] property, [[api/building_function|BUILDING_FUNCTION]], or other [[assets|ASSET]]/[[api#data_classes|DATA]] class you can use the string Id to reference it by name. When you want to use your new ASSET instance be it in a [[api/component|COMPONENT]] property, [[api/building_function|BUILDING_FUNCTION]], or other [[assets|ASSET]]/[[api#data_classes|DATA]] class you can use the string Id to reference it by name.
  
-For example here we are using our custom ASSET instance as the default value in a [[api/component|COMPONENT]]+For example here we are using our custom [[assets|ASSET]] instance as the default value in a [[api/component|COMPONENT]]
 <code lua> <code lua>
 local COMP_EXAMPLE = { local COMP_EXAMPLE = {
custom-asset.1648601638.txt.gz · Last modified: 2022/03/29 20:53 by minotorious

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki