Skip to content

Commit

Permalink
save data after every skin change, since on_shutdown is not fail safe (
Browse files Browse the repository at this point in the history
…#3)

* save data after every skin change, since on_shutdown is not fail safe
* remove unnecessary saving of data on shutdown
  • Loading branch information
dr4Ke authored and sofar committed Jun 24, 2016
1 parent 377d40c commit 190ffb6
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions init.lua
Expand Up @@ -100,12 +100,6 @@ if input then
input:close()
end

minetest.register_on_shutdown(function()
local output = io.open(datafile, "w")
output:write(minetest.serialize(playerdata))
output:close()
end)

local skin_def = {
gender = "Male",
height = 1,
Expand Down Expand Up @@ -149,6 +143,11 @@ local function change_skin(player)
else
player:set_properties({textures={texture}})
end

-- Save data
local output = io.open(datafile, "w")
output:write(minetest.serialize(playerdata))
output:close()
end

minetest.register_on_joinplayer(function(player)
Expand Down

0 comments on commit 190ffb6

Please sign in to comment.