mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-12-25 18:20:36 +01:00
Merge branch 'master' of https://github.com/MinetestForFun/minetest-minetestforfun-server
This commit is contained in:
commit
8dae42cd3d
@ -31,40 +31,6 @@ dofile(minetest.get_modpath("pclasses") .. "/api.lua")
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
---------------------------
|
|
||||||
-- Backup and load system
|
|
||||||
--
|
|
||||||
|
|
||||||
-- Startup
|
|
||||||
local pfile = io.open(pclasses.conf.datafile, "r")
|
|
||||||
if pfile then
|
|
||||||
local line = pfile:read()
|
|
||||||
if line then
|
|
||||||
pclasses.datas.players = minetest.deserialize(line)
|
|
||||||
end
|
|
||||||
pfile:close()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Frequent backup
|
|
||||||
local function save_datas()
|
|
||||||
local pfile = io.open(pclasses.conf.datafile, "w")
|
|
||||||
pfile:write(minetest.serialize(pclasses.datas.players))
|
|
||||||
pfile:close()
|
|
||||||
minetest.log("action", "[PClasses] Datas saved")
|
|
||||||
end
|
|
||||||
|
|
||||||
local save_timer = 0
|
|
||||||
minetest.register_globalstep(function(dtime)
|
|
||||||
save_timer = save_timer + dtime
|
|
||||||
if save_timer >= pclasses.conf.save_interval then
|
|
||||||
save_datas()
|
|
||||||
save_timer = 0
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
minetest.register_on_shutdown(save_datas)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
------------------
|
------------------
|
||||||
-- Default class
|
-- Default class
|
||||||
--
|
--
|
||||||
|
Loading…
Reference in New Issue
Block a user