Work in progress--does not work yet.

Don't pull this. It is not stable.
This commit is contained in:
Robbie Ferguson 2016-05-10 13:42:17 -04:00
parent 2aa11d8ab1
commit 654224d2c8

@ -65,33 +65,37 @@ end
local function tpc_send(player,coordinates)
local x,y,z = string.match(coordinates, "^(-?%d+),(-?%d+),(-?%d+)$")
local pname = minetest.get_player_by_name(player)
if x==nil or y==nil or z==nil or string.len(x) > 6 or string.len(y) > 6 or string.len(z) > 6 then
minetest.chat_send_player(player, "Usage: /tpc <x,y,z>")
minetest.chat_send_player(pname, "Usage: /tpc <x,y,z>")
return nil
end
x = x + 0.0
y = y + 0.0
z = z + 0.0
x = tonumber(x) + 0.0
y = tonumber(y) + 0.0
z = tonumber(z) + 0.0
if x > 32765 or x < -32765 or y > 32765 or y < -32765 or z > 32765 or z < -32765 then
minetest.chat_send_player(player, "Error: Invalid coordinates.")
minetest.chat_send_player(pname, "Error: Invalid coordinates.")
return nil
end
local meta = minetest.env:get_meta(pos)
local target_coords={x=meta:get_float("x"), y=meta:get_float("y"), z=meta:get_float("z")}
-- If the area is protected, reject the user's request to teleport to these coordinates
-- In future release we'll actually query the player who owns the area, if they're online, and ask for their permission.
local protected = minetest.is_protected(coordinates)
local protected = minetest.is_protected(target_coords)
if protected then
minetest.chat_send_player(player, "Error: These coordinates are within a protected area.")
minetest.chat_send_player(pname, "Error: These coordinates are within a protected area.")
return
end
minetest.chat_send_player(player, 'Teleporting to '.. coordinates)
local target_coords={x=meta:get_float("x"), y=meta:get_float("y"), z=meta:get_float("z")}
minetest.sound_play("tps_portal", {pos = target_coords, gain = 1.0, max_hear_distance = 10,})
player:moveto(target_coords, false)
minetest.chat_send_player(pname, 'Teleporting to '..x..','..y..','..z)
minetest.sound_play("tps_portal", {pos = target_coords, gain = 1.0, max_hear_distance = 10})
player:sendto(target_coords, false)
end
local function tpr_deny(name)