Skip to content

Commit

Permalink
Avoid teleporting player if /teleport coords are out-of-range
Browse files Browse the repository at this point in the history
  • Loading branch information
tenplus1 authored and Zeno- committed Apr 28, 2016
1 parent dc35091 commit 7baddd1
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions builtin/game/chatcommands.lua
Expand Up @@ -352,10 +352,16 @@ core.register_chatcommand("teleport", {
p.x = tonumber(p.x)
p.y = tonumber(p.y)
p.z = tonumber(p.z)
teleportee = core.get_player_by_name(name)
if teleportee and p.x and p.y and p.z then
teleportee:setpos(p)
return true, "Teleporting to "..core.pos_to_string(p)
if p.x and p.y and p.z then
local lm = tonumber(minetest.setting_get("map_generation_limit") or 31000)
if p.x < -lm or p.x > lm or p.y < -lm or p.y > lm or p.z < -lm or p.z > lm then
return false, "Cannot teleport out of map bounds!"
end
teleportee = core.get_player_by_name(name)
if teleportee then
teleportee:setpos(p)
return true, "Teleporting to "..core.pos_to_string(p)
end
end

local teleportee = nil
Expand Down

0 comments on commit 7baddd1

Please sign in to comment.