Log static_spawn error only once

This commit is contained in:
Rui 2015-10-11 21:25:58 +09:00 committed by Nils Dagsson Moskopp
parent 78d2dee49e
commit aedf15826c
Signed by: erle
GPG Key ID: A3BC671C35191080
1 changed files with 7 additions and 15 deletions

View File

@ -3,31 +3,23 @@
local function warn_invalid_static_spawnpoint() local function warn_invalid_static_spawnpoint()
if core.setting_get("static_spawnpoint") and if core.setting_get("static_spawnpoint") and
not core.setting_get_pos("static_spawnpoint") then not core.setting_get_pos("static_spawnpoint") then
core.log('error', "The static_spawnpoint setting is invalid: \"".. core.log("error", "The static_spawnpoint setting is invalid: \""..
core.setting_get("static_spawnpoint").."\"") core.setting_get("static_spawnpoint").."\"")
end end
end end
warn_invalid_static_spawnpoint() warn_invalid_static_spawnpoint()
local function put_player_in_spawn(obj) local function put_player_in_spawn(player_obj)
warn_invalid_static_spawnpoint()
local static_spawnpoint = core.setting_get_pos("static_spawnpoint") local static_spawnpoint = core.setting_get_pos("static_spawnpoint")
if not static_spawnpoint then if not static_spawnpoint then
return false return false
end end
core.log('action', "Moving "..obj:get_player_name().. core.log("action", "Moving " .. player_obj:get_player_name() ..
" to static spawnpoint at ".. " to static spawnpoint at " .. core.pos_to_string(static_spawnpoint))
core.pos_to_string(static_spawnpoint)) player_obj:setpos(static_spawnpoint)
obj:setpos(static_spawnpoint)
return true return true
end end
core.register_on_newplayer(function(obj) core.register_on_newplayer(put_player_in_spawn)
put_player_in_spawn(obj) core.register_on_respawnplayer(put_player_in_spawn)
end)
core.register_on_respawnplayer(function(obj)
return put_player_in_spawn(obj)
end)