User Tools

Site Tools


custom-data

Differences

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

Link to this comparison view

custom-data [2022/03/29 20:45] – created minotoriouscustom-data [2022/03/29 20:58] (current) minotorious
Line 1: Line 1:
-DATA classes are the most basic type in Foundation that all other types are based on.+[[api#data_classes|DATA]] classes are the most basic type in Foundation that all other types are based on.
  
-For reference all available pure DATA classes can be found in [[api#data_classes|this]] section of the API.+For reference all available pure [[api#data_classes|DATA]] classes can be found in [[api#data_classes|this]] section of the API.
  
 ===== Creating & Using a Custom DATA Object ===== ===== Creating & Using a Custom DATA Object =====
 ==== Step 1: Defining a DATA Object using a Lua Table ==== ==== Step 1: Defining a DATA Object using a Lua Table ====
-To create a custom DATA object we will need to make use of the ''mod:registerClass(DataTable)'' function providing it with an associated Lua Table.+To create a custom [[api#data_classes|DATA]] object we will need to make use of the ''mod:registerClass(DataTable)'' function providing it with an associated Lua Table.
  
-Here you decide what properties your custom DATA object will contain. +Here you decide what properties your custom [[api#data_classes|DATA]] object will contain. 
 <code lua> <code lua>
 local MY_DATA_OBJECT = { local MY_DATA_OBJECT = {
Line 22: Line 22:
 Make sure not to forget the ''SAVE_GAME'' flag if you intend to store runtime values that need to persist accross a reload! Make sure not to forget the ''SAVE_GAME'' flag if you intend to store runtime values that need to persist accross a reload!
  
-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: Using a DATA Object ==== ==== Step 2: Using a DATA Object ====
-Note: This also aplies to using vanilla DATA Objects!+Note: This also aplies to using vanilla [[api#data_classes|DATA]] Objects!
  
-During gameplay when you will need to instantiate a DATA object you will have to use the ''foundation.createData(...)'' method as follows.+During gameplay when you will need to instantiate a [[api#data_classes|DATA]] object you will have to use the ''foundation.createData(...)'' method as follows.
 <code lua> <code lua>
 local myData = foundation.createData( local myData = foundation.createData(
Line 39: Line 39:
 In case you omit any properties you don't yet need to explicitly set they will use their default values until otherwise specified. As we have done with''Property2'' above. In case you omit any properties you don't yet need to explicitly set they will use their default values until otherwise specified. As we have done with''Property2'' above.
  
-If you want to alter a property after the DATA object has been instantiated you can of course do so at will like this.+If you want to alter a property after the [[api#data_classes|DATA]] object has been instantiated you can of course do so at will like this.
 <code lua> <code lua>
 myData.Property1 = "SomeAlteredString" myData.Property1 = "SomeAlteredString"
 </code> </code>
custom-data.1648601113.txt.gz · Last modified: 2022/03/29 20:45 by minotorious

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki