mail/persistence.lua

19 lines
479 B
Lua
Raw Normal View History

2018-12-05 11:06:25 +01:00
function mail.load()
local file = io.open(minetest.get_worldpath().."/mail.db","r")
if file then
local data = file:read("*a")
mail.messages = minetest.deserialize(data)
file:close()
end
end
function mail.save()
local file = io.open(minetest.get_worldpath().."/mail.db","w")
if file and file:write(minetest.serialize(mail.messages)) and file:close() then
return true
else
minetest.log("error","[mail] Save failed - messages may be lost!")
return false
end
end