mirror of
https://github.com/minetest-mods/teleport-request.git
synced 2025-01-08 22:17:27 +01:00
Make /tpj require interact priv and recode /tpj
Also make it so Minetest checks for the tp_tpc priv rather than our function.
This commit is contained in:
parent
9af1969f37
commit
9778db4268
43
init.lua
43
init.lua
@ -212,46 +212,46 @@ local function tpr_accept(name, param)
|
|||||||
parti2(target_coords)
|
parti2(target_coords)
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_chatcommand("tpj", {
|
-- Teleport Jump - Relative Position Teleportation by number of nodes
|
||||||
params = "<Axis> <Number>",
|
local function tpj(name,param)
|
||||||
description = "Relative Teleportation",
|
local pname = minetest.get_player_by_name(player)
|
||||||
privs = {teleport = true},
|
|
||||||
func = function(name,param)
|
|
||||||
currPos = minetest.get_player_by_name(name):getpos()
|
|
||||||
if param == "" then
|
if param == "" then
|
||||||
minetest.chat_send_player(name, "Incorrect usage. <X|Y|Z> <Number>")
|
minetest.chat_send_player(player, "Usage. <X|Y|Z> <Number>")
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local args = param:split(" ")
|
local args = param:split(" ")
|
||||||
if #args < 2 then
|
if #args < 2 then
|
||||||
minetest.chat_send_player(name, "Incorrect usage. <X|Y|Z> <Number>")
|
minetest.chat_send_player(player, "Usage. <X|Y|Z> <Number>")
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
if not tonumber(args[2]) then
|
if not tonumber(args[2]) then
|
||||||
return false, "Not a Number!"
|
return false, "Not a Number!"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Initially generate the target coords from the player's current position (since it's relative) and then perform the math.
|
||||||
|
local target_coords = minetest.get_player_by_name(name):getpos()
|
||||||
if args[1] == "x" then
|
if args[1] == "x" then
|
||||||
currPos["x"] = currPos["x"] + tonumber(args[2])
|
target_coords["x"] = target_coords["x"] + tonumber(args[2])
|
||||||
minetest.get_player_by_name(name):setpos(currPos)
|
pname:setpos(find_free_position_near(target_coords))
|
||||||
minetest.sound_play("whoosh", {pos = target_coords, gain = 0.5, max_hear_distance = 10})
|
minetest.sound_play("whoosh", {pos = target_coords, gain = 0.5, max_hear_distance = 10})
|
||||||
parti2(target_coords)
|
parti2(target_coords)
|
||||||
elseif args[1] == "y" then
|
elseif args[1] == "y" then
|
||||||
currPos["y"] = currPos["y"] + tonumber(args[2])
|
target_coords["y"] = target_coords["y"] + tonumber(args[2])
|
||||||
minetest.get_player_by_name(name):setpos(currPos)
|
pname:setpos(find_free_position_near(target_coords))
|
||||||
minetest.sound_play("whoosh", {pos = target_coords, gain = 0.5, max_hear_distance = 10})
|
minetest.sound_play("whoosh", {pos = target_coords, gain = 0.5, max_hear_distance = 10})
|
||||||
parti2(target_coords)
|
parti2(target_coords)
|
||||||
elseif args[1] == "z" then
|
elseif args[1] == "z" then
|
||||||
currPos["z"] = currPos["z"] + tonumber(args[2])
|
target_coords["z"] = target_coords["z"] + tonumber(args[2])
|
||||||
minetest.get_player_by_name(name):setpos(currPos)
|
pname:setpos(find_free_position_near(target_coords))
|
||||||
minetest.sound_play("whoosh", {pos = target_coords, gain = 0.5, max_hear_distance = 10})
|
minetest.sound_play("whoosh", {pos = target_coords, gain = 0.5, max_hear_distance = 10})
|
||||||
parti2(target_coords)
|
parti2(target_coords)
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(name,"Not valid axis")
|
minetest.chat_send_player(player,"Not a valid axis. Valid options are X, Y or Z.")
|
||||||
end
|
end
|
||||||
end,
|
end
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_chatcommand("tpr", {
|
minetest.register_chatcommand("tpr", {
|
||||||
description = "Request teleport to another player",
|
description = "Request teleport to another player",
|
||||||
@ -270,10 +270,17 @@ minetest.register_chatcommand("tphr", {
|
|||||||
minetest.register_chatcommand("tpc", {
|
minetest.register_chatcommand("tpc", {
|
||||||
description = "Teleport to coordinates",
|
description = "Teleport to coordinates",
|
||||||
params = "<coordinates> | leave coordinates empty to see help message",
|
params = "<coordinates> | leave coordinates empty to see help message",
|
||||||
privs = {interact=true},
|
privs = {interact=true,tp_tpc=true},
|
||||||
func = tpc_send
|
func = tpc_send
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_chatcommand("tpj", {
|
||||||
|
description = "Teleport to relative position",
|
||||||
|
params = "<axis> <distance> | leave empty to see help message",
|
||||||
|
privs = {interact=true},
|
||||||
|
func = tpj
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_chatcommand("tpy", {
|
minetest.register_chatcommand("tpy", {
|
||||||
description = "Accept teleport requests from another player",
|
description = "Accept teleport requests from another player",
|
||||||
func = tpr_accept
|
func = tpr_accept
|
||||||
|
Loading…
Reference in New Issue
Block a user