static_spawn.lua 790 B

1234567891011121314151617181920212223
  1. -- Minetest: builtin/static_spawn.lua
  2. local static_spawnpoint_string = core.settings:get("static_spawnpoint")
  3. if static_spawnpoint_string and
  4. static_spawnpoint_string ~= "" and
  5. not core.setting_get_pos("static_spawnpoint") then
  6. error('The static_spawnpoint setting is invalid: "' ..
  7. static_spawnpoint_string .. '"')
  8. end
  9. local function put_player_in_spawn(player_obj)
  10. local static_spawnpoint = core.setting_get_pos("static_spawnpoint")
  11. if not static_spawnpoint then
  12. return false
  13. end
  14. core.log("action", "Moving " .. player_obj:get_player_name() ..
  15. " to static spawnpoint at " .. core.pos_to_string(static_spawnpoint))
  16. player_obj:setpos(static_spawnpoint)
  17. return true
  18. end
  19. core.register_on_newplayer(put_player_in_spawn)
  20. core.register_on_respawnplayer(put_player_in_spawn)