Re-add static_spawn.lua (fixes #81)
This commit is contained in:
parent
fb78a8a0cd
commit
7f85835a8f
@ -25,6 +25,7 @@ dofile(gamepath .. "auth.lua")
|
|||||||
dofile(commonpath .. "chatcommands.lua")
|
dofile(commonpath .. "chatcommands.lua")
|
||||||
dofile(gamepath .. "chat.lua")
|
dofile(gamepath .. "chat.lua")
|
||||||
dofile(commonpath .. "information_formspecs.lua")
|
dofile(commonpath .. "information_formspecs.lua")
|
||||||
|
dofile(gamepath .. "static_spawn.lua")
|
||||||
dofile(gamepath .. "detached_inventory.lua")
|
dofile(gamepath .. "detached_inventory.lua")
|
||||||
assert(loadfile(gamepath .. "falling.lua"))(builtin_shared)
|
assert(loadfile(gamepath .. "falling.lua"))(builtin_shared)
|
||||||
dofile(gamepath .. "features.lua")
|
dofile(gamepath .. "features.lua")
|
||||||
|
23
builtin/game/static_spawn.lua
Normal file
23
builtin/game/static_spawn.lua
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
-- Minetest: builtin/static_spawn.lua
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
local function put_player_in_spawn(player_obj)
|
||||||
|
local static_spawnpoint = core.setting_get_pos("static_spawnpoint") or core.get_world_spawnpoint()
|
||||||
|
if not static_spawnpoint then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
core.log("action", "Moving " .. player_obj:get_player_name() ..
|
||||||
|
" to spawnpoint at " .. core.pos_to_string(static_spawnpoint))
|
||||||
|
player_obj:set_pos(static_spawnpoint)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
core.register_on_newplayer(put_player_in_spawn)
|
||||||
|
core.register_on_respawnplayer(put_player_in_spawn)
|
Loading…
x
Reference in New Issue
Block a user