2017-02-09 23:06:25 +01:00
|
|
|
skins.load_players = function()
|
|
|
|
local file = io.open(skins.file, "r")
|
2014-07-23 13:46:42 +02:00
|
|
|
if file then
|
|
|
|
for line in file:lines() do
|
|
|
|
local data = string.split(line, " ", 2)
|
2017-02-09 23:06:25 +01:00
|
|
|
skins.skins[data[1]] = data[2]
|
2014-03-17 06:26:58 +01:00
|
|
|
end
|
2014-07-23 13:46:42 +02:00
|
|
|
io.close(file)
|
2014-03-17 06:26:58 +01:00
|
|
|
end
|
|
|
|
end
|
2017-02-09 23:06:25 +01:00
|
|
|
skins.load_players()
|
2014-07-23 13:46:42 +02:00
|
|
|
|
|
|
|
local ttime = 0
|
|
|
|
minetest.register_globalstep(function(t)
|
|
|
|
ttime = ttime + t
|
|
|
|
if ttime < 360 then --every 6min'
|
|
|
|
return
|
|
|
|
end
|
|
|
|
ttime = 0
|
2017-02-09 23:06:25 +01:00
|
|
|
skins.save()
|
2014-07-23 13:46:42 +02:00
|
|
|
end)
|
|
|
|
|
2017-02-09 23:06:25 +01:00
|
|
|
minetest.register_on_shutdown(function() skins.save() end)
|
2014-03-17 06:26:58 +01:00
|
|
|
|
2017-02-09 23:06:25 +01:00
|
|
|
skins.save = function()
|
|
|
|
if not skins.file_save then
|
2014-07-23 13:46:42 +02:00
|
|
|
return
|
|
|
|
end
|
2017-02-09 23:06:25 +01:00
|
|
|
skins.file_save = false
|
|
|
|
local output = io.open(skins.file, "w")
|
|
|
|
for name, skin in pairs(skins.skins) do
|
2014-03-17 06:26:58 +01:00
|
|
|
if name and skin then
|
2017-02-09 23:06:25 +01:00
|
|
|
if skin ~= skins.default then
|
2014-07-23 13:46:42 +02:00
|
|
|
output:write(name.." "..skin.."\n")
|
|
|
|
end
|
2014-03-17 06:26:58 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
io.close(output)
|
|
|
|
end
|
|
|
|
|