2014-12-01 11:11:34 -08:00
|
|
|
|
2014-12-03 11:38:49 -08:00
|
|
|
spawn_command = {}
|
|
|
|
spawn_command.pos = {x=0, y=3, z=0}
|
|
|
|
|
|
|
|
if minetest.setting_get_pos("static_spawnpoint") then
|
|
|
|
spawn_command.pos = minetest.setting_get_pos("static_spawnpoint")
|
|
|
|
end
|
|
|
|
|
2014-12-01 11:11:34 -08:00
|
|
|
minetest.register_chatcommand("spawn", {
|
2014-12-03 11:38:49 -08:00
|
|
|
description = "Teleport you to spawn point.",
|
2014-12-01 11:11:34 -08:00
|
|
|
func = function(name)
|
2014-12-03 11:38:49 -08:00
|
|
|
local player = minetest.get_player_by_name(name)
|
2014-12-01 11:11:34 -08:00
|
|
|
if player == nil then
|
|
|
|
-- just a check to prevent the server crashing
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
local pos = player:getpos()
|
|
|
|
if pos.x>-20 and pos.x<20 and pos.y>-20 and pos.z>-20 and pos.z<20 then
|
|
|
|
|
|
|
|
else
|
2014-12-03 11:38:49 -08:00
|
|
|
player:setpos(spawn_command.pos)
|
2014-12-01 11:11:34 -08:00
|
|
|
minetest.chat_send_player(name, "Teleported to spawn!")
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
})
|