X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=builtin%2Fgame%2Fstatic_spawn.lua;h=fae23eab0726a841bb2926a2ec39561e24480376;hb=9c725609c3e2516c9dae8f4515f888d99de80a48;hp=e8c107d86a3c364da1f3645ebbfbfb9443aa36e7;hpb=1cd512913e4d4ad1fb43d4b6e3d7971bb6c67528;p=dragonfireclient.git diff --git a/builtin/game/static_spawn.lua b/builtin/game/static_spawn.lua index e8c107d86..fae23eab0 100644 --- a/builtin/game/static_spawn.lua +++ b/builtin/game/static_spawn.lua @@ -1,33 +1,23 @@ -- Minetest: builtin/static_spawn.lua -local function warn_invalid_static_spawnpoint() - if minetest.setting_get("static_spawnpoint") and - not minetest.setting_get_pos("static_spawnpoint") then - minetest.log('error', "The static_spawnpoint setting is invalid: \"".. - minetest.setting_get("static_spawnpoint").."\"") - end +local static_spawnpoint_string = core.settings:get("static_spawnpoint") +if static_spawnpoint_string and + static_spawnpoint_string ~= "" and + not core.setting_get_pos("static_spawnpoint") then + error('The static_spawnpoint setting is invalid: "' .. + static_spawnpoint_string .. '"') end -warn_invalid_static_spawnpoint() - -local function put_player_in_spawn(obj) - warn_invalid_static_spawnpoint() - local static_spawnpoint = minetest.setting_get_pos("static_spawnpoint") +local function put_player_in_spawn(player_obj) + local static_spawnpoint = core.setting_get_pos("static_spawnpoint") if not static_spawnpoint then return false end - minetest.log('action', "Moving "..obj:get_player_name().. - " to static spawnpoint at ".. - minetest.pos_to_string(static_spawnpoint)) - obj:setpos(static_spawnpoint) + core.log("action", "Moving " .. player_obj:get_player_name() .. + " to static spawnpoint at " .. core.pos_to_string(static_spawnpoint)) + player_obj:set_pos(static_spawnpoint) return true end -minetest.register_on_newplayer(function(obj) - put_player_in_spawn(obj) -end) - -minetest.register_on_respawnplayer(function(obj) - return put_player_in_spawn(obj) -end) - +core.register_on_newplayer(put_player_in_spawn) +core.register_on_respawnplayer(put_player_in_spawn)