Make sure that coordinates passed to /teleport are actual numbers

stable-0.4
PilzAdam 2013-07-08 13:30:55 +02:00
parent a75afb85ca
commit 0b5f18754c
1 changed files with 6 additions and 0 deletions

View File

@ -272,6 +272,9 @@ minetest.register_chatcommand("teleport", {
local teleportee = nil local teleportee = nil
local p = {} local p = {}
p.x, p.y, p.z = string.match(param, "^([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+)$") p.x, p.y, p.z = string.match(param, "^([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+)$")
p.x = tonumber(p.x)
p.y = tonumber(p.y)
p.z = tonumber(p.z)
teleportee = minetest.get_player_by_name(name) teleportee = minetest.get_player_by_name(name)
if teleportee and p.x and p.y and p.z then if teleportee and p.x and p.y and p.z then
minetest.chat_send_player(name, "Teleporting to ("..p.x..", "..p.y..", "..p.z..")") minetest.chat_send_player(name, "Teleporting to ("..p.x..", "..p.y..", "..p.z..")")
@ -302,6 +305,9 @@ minetest.register_chatcommand("teleport", {
local p = {} local p = {}
local teleportee_name = nil local teleportee_name = nil
teleportee_name, p.x, p.y, p.z = string.match(param, "^([^ ]+) +([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+)$") teleportee_name, p.x, p.y, p.z = string.match(param, "^([^ ]+) +([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+)$")
p.x = tonumber(p.x)
p.y = tonumber(p.y)
p.z = tonumber(p.z)
if teleportee_name then if teleportee_name then
teleportee = minetest.get_player_by_name(teleportee_name) teleportee = minetest.get_player_by_name(teleportee_name)
end end