Add save()
and load()
Data will be stored in `<world>/tell.txt`
This commit is contained in:
parent
1bb4acd2ae
commit
2a84d977ee
26
init.lua
26
init.lua
@ -1 +1,27 @@
|
||||
-- tell/init.lua
|
||||
|
||||
tell = {}
|
||||
|
||||
local list = {}
|
||||
|
||||
-- [local function] Load
|
||||
local function load()
|
||||
local res = io.open(minetest.get_worldpath().."/tell.txt", "r")
|
||||
if res then
|
||||
res = minetest.deserialize(res:read("*all"))
|
||||
if type(res) == "table" then
|
||||
list = res
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- [local function] Save
|
||||
local function save()
|
||||
io.open(minetest.get_worldpath().."/tell.txt", "w"):write(minetest.serialize(list))
|
||||
end
|
||||
|
||||
-- Load
|
||||
load()
|
||||
|
||||
-- [register] On shutdown
|
||||
minetest.register_on_shutdown(save)
|
||||
|
Loading…
x
Reference in New Issue
Block a user