2012-04-09 13:29:55 -07:00
|
|
|
-- Minetest: builtin/static_spawn.lua
|
|
|
|
|
|
|
|
local function warn_invalid_static_spawnpoint()
|
2014-04-27 18:02:48 -07:00
|
|
|
if core.setting_get("static_spawnpoint") and
|
|
|
|
not core.setting_get_pos("static_spawnpoint") then
|
2015-10-11 05:25:58 -07:00
|
|
|
core.log("error", "The static_spawnpoint setting is invalid: \""..
|
2014-04-27 18:02:48 -07:00
|
|
|
core.setting_get("static_spawnpoint").."\"")
|
2012-04-09 13:29:55 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
warn_invalid_static_spawnpoint()
|
|
|
|
|
2015-10-11 05:25:58 -07:00
|
|
|
local function put_player_in_spawn(player_obj)
|
2014-04-27 18:02:48 -07:00
|
|
|
local static_spawnpoint = core.setting_get_pos("static_spawnpoint")
|
2012-04-09 13:29:55 -07:00
|
|
|
if not static_spawnpoint then
|
|
|
|
return false
|
|
|
|
end
|
2015-10-11 05:25:58 -07:00
|
|
|
core.log("action", "Moving " .. player_obj:get_player_name() ..
|
|
|
|
" to static spawnpoint at " .. core.pos_to_string(static_spawnpoint))
|
|
|
|
player_obj:setpos(static_spawnpoint)
|
2012-04-09 13:29:55 -07:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2015-10-11 05:25:58 -07:00
|
|
|
core.register_on_newplayer(put_player_in_spawn)
|
|
|
|
core.register_on_respawnplayer(put_player_in_spawn)
|