Yes, there are tables that will be saved and restored when the player comes back.
Saving Lua data persistently
So called storage tables can be used to to store data in a persistent way.
City.getStorage()
Is saved within the city file, so it's useful to save city dependent stuff in it.
TheoTown.getStorage()
A single table that is stored globally for the game. So you could put things in here that should not be city dependent.
Usage
Since your plugin has to share the storage tables with all other exisiting plugins you may want some sort of private table within it. You can do that by using the helper function
Util.optStorage() which manages creation, insertion and retrival of a table using a given key.
Code: Select all
-- Let's use a unique, own key for the table that we will create within a storage table
local key = script:getDraft():getId()
-- Let's get our personal storage table within the city storage table (will be created if it doesn't exist)
local table = Util.optStorage(City.getStorage(), key)
-- Let's put something into it; this should still be there after saving the city, ending the game, and then coming back
table.x = 42
There are no explicit save functions for the storage tables since they will be saved together with other data automatically.
Limitations
You cannot save functions in a storage table persistently.