Change file structures so that the interior modpol folder IS the portable modpol.
Added documentation of how to pre-define the modpath and the storage file.
This commit is contained in:
34
modpol_minetest/storage/storage-mod_storage.lua
Normal file
34
modpol_minetest/storage/storage-mod_storage.lua
Normal file
@ -0,0 +1,34 @@
|
||||
-- ===================================================================
|
||||
-- /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
|
Reference in New Issue
Block a user