diff --git a/init.lua b/init.lua index 784bf89..70981fd 100644 --- a/init.lua +++ b/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") diff --git a/registry.lua b/registry.lua index e4b2ddc..93e69bc 100644 --- a/registry.lua +++ b/registry.lua @@ -9,4 +9,19 @@ end function pick_and_place.get_template(id) return registry[id] -end \ No newline at end of file +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) \ No newline at end of file