diff --git a/init.lua b/init.lua index 0dd2166..7c65c38 100644 --- a/init.lua +++ b/init.lua @@ -115,6 +115,17 @@ end --fun_caves.print_recipes() +-- Attempt to save data at shutdown (as well as periodically). +minetest.register_on_shutdown(function() + local out = io.open(fun_caves.world..'/fun_caves_data.txt','w') + if out then + print('Fun Caves: Saving database at shutdown') + out:write(minetest.serialize(fun_caves.db)) + out.close() + end +end) + + local hunger_mod = minetest.get_modpath("hunger") fun_caves.hunger_id = {}