ON THIS PAGE
CUSTOM ITEM DATA
SAVED LIVE DATA
Saved Live Data is for data that can be changed per item instance that is not included in the base item struct. This can be used for things like equipped weapon attachments or current ammo, durability values for armour, battery charge for a torch, and so on.
Saved Live Data is stored as a series of strings. This data can be converted to and from these strings in the item’s Data Asset, allowing for any kind of information for any item to be stored in the generic ST_ItemLiveData struct. String conversion functions are provided in the Data Asset for variable types that don’t have native conversions, such as Transforms and Soft Object and Class references.
Care must be taken when defining your stat conversions in your Data Asset to ensure that the order in which they are converted is the same both ways. For example, a weapon may have Current Ammo (int) and Fire Mode (Enum).
-
Conversion would be defined in your weapon Data Asset as:
-
Current Ammo: Int to String as String[0]
-
Fire Mode: Enum Byte to String as String[1]
-
This would be saved to the struct.
-
-
Conversion the other way would then have to be:
-
String[0]: String to int as Current Ammo (int)
-
String[1]: String to Byte, Byte to enum Fire Mode (enum)
-
It is recommended when accessing individual stats from the Saved Live Data to have dedicated getter functions for these.
For example, if Current Ammo is needed, create a pure GetCurrentAmmo function on the weapon’s Data Asset that takes Saved Live Data as an input. Do SavedLiveData[0] to int and return that int value as Current Ammo to be used. This will keep the code simple and easier to read when accessing these variables, and will ensure that the correct String value is always used to prevent accidental misuse.