mirror of
https://github.com/minetest/minetest.git
synced 2024-11-24 00:23:46 +01:00
43d1f375d1
This unifies the settings APIs. This also unifies the sync and async registration APIs, since the async registration API did not support adding non-functions to the API table.
26 lines
811 B
Lua
26 lines
811 B
Lua
-- Minetest: builtin/static_spawn.lua
|
|
|
|
local function warn_invalid_static_spawnpoint()
|
|
if core.settings:get("static_spawnpoint") and
|
|
not core.setting_get_pos("static_spawnpoint") then
|
|
core.log("error", "The static_spawnpoint setting is invalid: \""..
|
|
core.settings:get("static_spawnpoint").."\"")
|
|
end
|
|
end
|
|
|
|
warn_invalid_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
|
|
core.log("action", "Moving " .. player_obj:get_player_name() ..
|
|
" to static spawnpoint at " .. core.pos_to_string(static_spawnpoint))
|
|
player_obj:setpos(static_spawnpoint)
|
|
return true
|
|
end
|
|
|
|
core.register_on_newplayer(put_player_in_spawn)
|
|
core.register_on_respawnplayer(put_player_in_spawn)
|