1
0
mirror of https://github.com/moparisthebest/minetest synced 2024-12-23 08:08:47 -05:00
minetest/builtin/game/static_spawn.lua

34 lines
879 B
Lua
Raw Normal View History

2012-04-09 16:29:55 -04:00
-- Minetest: builtin/static_spawn.lua
local function warn_invalid_static_spawnpoint()
2014-04-27 21:02:48 -04:00
if core.setting_get("static_spawnpoint") and
not core.setting_get_pos("static_spawnpoint") then
core.log('error', "The static_spawnpoint setting is invalid: \""..
core.setting_get("static_spawnpoint").."\"")
2012-04-09 16:29:55 -04:00
end
end
warn_invalid_static_spawnpoint()
local function put_player_in_spawn(obj)
warn_invalid_static_spawnpoint()
2014-04-27 21:02:48 -04:00
local static_spawnpoint = core.setting_get_pos("static_spawnpoint")
2012-04-09 16:29:55 -04:00
if not static_spawnpoint then
return false
end
2014-04-27 21:02:48 -04:00
core.log('action', "Moving "..obj:get_player_name()..
2012-04-09 16:29:55 -04:00
" to static spawnpoint at "..
2014-04-27 21:02:48 -04:00
core.pos_to_string(static_spawnpoint))
2012-04-09 16:29:55 -04:00
obj:setpos(static_spawnpoint)
return true
end
2014-04-27 21:02:48 -04:00
core.register_on_newplayer(function(obj)
2012-04-09 16:29:55 -04:00
put_player_in_spawn(obj)
end)
2014-04-27 21:02:48 -04:00
core.register_on_respawnplayer(function(obj)
2012-04-09 16:29:55 -04:00
return put_player_in_spawn(obj)
end)