reset score on exit/abort

master
BuckarooBanzay 2020-03-06 09:19:43 +01:00
parent 756c8bf461
commit 1ab6240f94
2 changed files with 17 additions and 0 deletions

16
cleanup.lua Normal file
View File

@ -0,0 +1,16 @@
local function cleanup(playername)
local player = minetest.get_player_by_name(playername)
if player then
local meta = player:get_meta()
meta:set_int("epic_score", 0)
end
end
-- clear score on epic abort/exit
epic.register_hook({
-- called on epic exit
on_epic_exit = cleanup,
on_epic_abort = cleanup,
})

View File

@ -10,6 +10,7 @@ local MP = minetest.get_modpath("epic_score")
-- utils
dofile(MP.."/persistence.lua")
dofile(MP.."/cleanup.lua")
-- hud
dofile(MP.."/hud.lua")