persist template metadata
This commit is contained in:
parent
2a970a5074
commit
4b7be7442a
4
init.lua
4
init.lua
@ -1,5 +1,7 @@
|
||||
|
||||
pick_and_place = {}
|
||||
pick_and_place = {
|
||||
store = minetest.get_mod_storage()
|
||||
}
|
||||
|
||||
local MP = minetest.get_modpath("pick_and_place")
|
||||
dofile(MP .. "/common.lua")
|
||||
|
17
registry.lua
17
registry.lua
@ -9,4 +9,19 @@ end
|
||||
|
||||
function pick_and_place.get_template(id)
|
||||
return registry[id]
|
||||
end
|
||||
end
|
||||
|
||||
local function load()
|
||||
local json = pick_and_place.store:get_string("registry")
|
||||
if json ~= "" then
|
||||
registry = minetest.parse_json(json, {})
|
||||
end
|
||||
end
|
||||
|
||||
load()
|
||||
|
||||
local function save()
|
||||
pick_and_place.store:set_string("registry", minetest.write_json(registry))
|
||||
end
|
||||
|
||||
minetest.register_on_shutdown(save)
|
Loading…
x
Reference in New Issue
Block a user