12345678910111213141516171819202122232425262728293031323334 |
- -- ===================================================================
- -- /storage-mod_storage.lua
- -- Persistent storage via Minetest's mod_storage method
- -- See https://dev.minetest.net/StorageRef
- -- Loads content of stored orgs and ledger from mod_storage
- --get modstorageref
- local mod_storage = minetest.get_mod_storage()
- modpol.load_storage = function()
-
- -- load orgs
- local stored_orgs = minetest.deserialize(mod_storage:get_string("orgs"))
- if (stored_orgs ~= nil) then
- modpol.orgs = stored_orgs
- end
- -- load orgs
- local stored_ledger = minetest.deserialize(mod_storage:get_string("ledger"))
- if (stored_ledger ~= nil) then
- modpol.ledger = stored_ledger
- end
- end
- -- Stores content of current orgs and ledger to mod_storage
- modpol.store_data = function()
- -- write to storage
- mod_storage:set_string("orgs", minetest.serialize(modpol.orgs))
- mod_storage:set_string("ledger", minetest.serialize(modpol.ledger))
- end
|