If you need to save some game data, you can use SaveManager.
All that you need is create an object with save() and load() function and add it to windowManager:
local object = {} function object:save(saveData) -- save data end function object:load(saveData) -- load data end fv.core.theSaveManager:addObject(object, 'myObject')
However, the better programming practice is to create a special class for this (see Classes for details):
MyClass = Class("MyClass") function MyClass:save(saveData) -- save data end function MyClass:load(saveData) -- load data end local instance = MyClass() fv.core.theSaveManager:addObject(instance, 'myModData')
Second argument of addObject() function is optional (but highly recommended) name of object.
Save/load[]
When game is saving SaveManager calls save() function. The only argument is empty lua-table "saveData". Feel free to fill any fields of this table by strings, numbers, bool values or subtables.
function MyClass:save(saveData) saveData.data = self.data saveData.uid = uidToStr(self.building.uid) saveData.num = 14 end
Warning! Do not place objects in this table. You can save UID instead.
Loading process is straightforward:
function MyClass:load(saveData) self.data = saveData.data self.building.uid = uidFromStr(saveData.uid) print(saveData.num) end