skinsdb/players.lua

41 lines
802 B
Lua
Raw Normal View History

2014-07-23 13:46:42 +02:00
u_skins.load_players = function()
local file = io.open(u_skins.file, "r")
if file then
for line in file:lines() do
local data = string.split(line, " ", 2)
2014-03-17 06:26:58 +01:00
u_skins.u_skins[data[1]] = data[2]
end
2014-07-23 13:46:42 +02:00
io.close(file)
2014-03-17 06:26:58 +01:00
end
end
2014-07-23 13:46:42 +02:00
u_skins.load_players()
local ttime = 0
minetest.register_globalstep(function(t)
ttime = ttime + t
if ttime < 360 then --every 6min'
return
end
ttime = 0
u_skins.save()
end)
minetest.register_on_shutdown(function() u_skins.save() end)
2014-03-17 06:26:58 +01:00
u_skins.save = function()
2014-07-23 13:46:42 +02:00
if not u_skins.file_save then
return
end
u_skins.file_save = false
local output = io.open(u_skins.file, "w")
2014-03-17 06:26:58 +01:00
for name, skin in pairs(u_skins.u_skins) do
if name and skin then
2014-07-30 17:49:51 +02:00
if skin ~= u_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