mirror of
https://github.com/minetest-mods/teleport-request.git
synced 2025-01-09 14:27:35 +01:00
Work in progress--does not work yet.
Don't pull this. It is not stable.
This commit is contained in:
parent
2aa11d8ab1
commit
654224d2c8
26
init.lua
26
init.lua
@ -65,33 +65,37 @@ end
|
|||||||
local function tpc_send(player,coordinates)
|
local function tpc_send(player,coordinates)
|
||||||
|
|
||||||
local x,y,z = string.match(coordinates, "^(-?%d+),(-?%d+),(-?%d+)$")
|
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
|
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
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
x = x + 0.0
|
x = tonumber(x) + 0.0
|
||||||
y = y + 0.0
|
y = tonumber(y) + 0.0
|
||||||
z = z + 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
|
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
|
return nil
|
||||||
end
|
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
|
-- 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.
|
-- 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
|
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
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.chat_send_player(player, 'Teleporting to '.. coordinates)
|
minetest.chat_send_player(pname, 'Teleporting to '..x..','..y..','..z)
|
||||||
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})
|
||||||
minetest.sound_play("tps_portal", {pos = target_coords, gain = 1.0, max_hear_distance = 10,})
|
player:sendto(target_coords, false)
|
||||||
player:moveto(target_coords, false)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function tpr_deny(name)
|
local function tpr_deny(name)
|
||||||
|
Loading…
Reference in New Issue
Block a user