[[api#data_classes|DATA]] classes are the most basic type in Foundation that all other types are based on. 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 ===== ==== 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. Here you decide what properties your custom [[api#data_classes|DATA]] object will contain. local MY_DATA_OBJECT = { TypeName = "MY_DATA_OBJECT ", Properties = { { Name = "Property1", Type = "string", Default = "SomeString", Flags = { "SAVE_GAME" }}, { Name = "Property2", Type = "list", Default = {} }, { Name = "Property3", Type = "integer", Default = 1 } } } mod:registerClass(MY_DATA_OBJECT) 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 [[api#data_classes|DATA]] or [[assets|ASSET]] objects, as well as ''list''s therof! ==== Step 2: Using a DATA Object ==== Note: This also aplies to using vanilla [[api#data_classes|DATA]] Objects! 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. local myData = foundation.createData( { DataType = "MY_DATA_OBJECT", Property1 = "SomeOtherString", Property3 = 5 } ) 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 [[api#data_classes|DATA]] object has been instantiated you can of course do so at will like this. myData.Property1 = "SomeAlteredString"