Add spawn and respawn to /goto command
This commit is contained in:
parent
aeaf92e2f7
commit
441a05a9a1
@ -592,7 +592,7 @@ end)
|
|||||||
|
|
||||||
minetest.register_chatcommand("goto", {
|
minetest.register_chatcommand("goto", {
|
||||||
privs = { teleport = true },
|
privs = { teleport = true },
|
||||||
params = S("<destination>"),
|
params = S("<destination> | spawn | respawn"),
|
||||||
description = S("Teleport to a destination"),
|
description = S("Teleport to a destination"),
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
local player = minetest.get_player_by_name(name)
|
local player = minetest.get_player_by_name(name)
|
||||||
@ -601,10 +601,25 @@ minetest.register_chatcommand("goto", {
|
|||||||
end
|
end
|
||||||
if param == "" then
|
if param == "" then
|
||||||
return false
|
return false
|
||||||
|
elseif param == "spawn" then
|
||||||
|
sf_world.go_to_spawn_pos(player)
|
||||||
|
return true
|
||||||
|
elseif param == "respawn" then
|
||||||
|
sf_world.go_to_respawn_pos(player)
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
local destination = tonumber(param)
|
local destination = tonumber(param)
|
||||||
if not destination or not sf_world.teleport_destinations[destination] then
|
if not destination or not sf_world.teleport_destinations[destination] then
|
||||||
return false, S("Invalid destination! Destination must be a number between 1 and @1.", #sf_world.teleport_destinations)
|
local destlist = {}
|
||||||
|
for k,v in pairs(sf_world.teleport_destinations) do
|
||||||
|
table.insert(destlist, k)
|
||||||
|
end
|
||||||
|
table.sort(destlist)
|
||||||
|
table.insert(destlist, "spawn")
|
||||||
|
table.insert(destlist, "respawn")
|
||||||
|
-- separate list with commas
|
||||||
|
local destlist_txt = table.concat(destlist, S(", "))
|
||||||
|
return false, S("Invalid destination! Valid destinations are: @1.", destlist_txt)
|
||||||
else
|
else
|
||||||
sf_world.teleport_to_destination(player, destination)
|
sf_world.teleport_to_destination(player, destination)
|
||||||
return true
|
return true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user