User Tools

Site Tools


custom-data

Differences

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

Link to this comparison view

Next revision
Previous revision
custom-data [2022/03/29 20:58] – created - external edit 127.0.0.1custom-data [2026/02/23 17:49] (current) – [Step 1: Defining a DATA Object using a Lua Table] polymorphgames
Line 5: Line 5:
 ===== 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 [[api#data_classes|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([[:class-info|classInfo]])'' function providing it with an associated Lua Table.
  
 Here you decide what properties your custom [[api#data_classes|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 = {
-    TypeName = "MY_DATA_OBJECT ",+    TypeName = "MY_DATA_OBJECT",
     Properties = {     Properties = {
         { Name = "Property1", Type = "string", Default = "SomeString", Flags = { "SAVE_GAME" }},         { Name = "Property1", Type = "string", Default = "SomeString", Flags = { "SAVE_GAME" }},
Line 20: Line 20:
 mod:registerClass(MY_DATA_OBJECT) mod:registerClass(MY_DATA_OBJECT)
 </code> </code>
-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 across 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 [[api#data_classes|DATA]] or [[assets|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!
custom-data.1648601925.txt.gz · Last modified: 2022/03/29 20:58 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki