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:
Robbie Ferguson 2016-05-18 07:40:42 -04:00
parent 9af1969f37
commit 9778db4268

@ -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
minetest.chat_send_player(name, "Incorrect usage. <X|Y|Z> <Number>")
return false
end
local args = param:split(" ") if param == "" then
if #args < 2 then minetest.chat_send_player(player, "Usage. <X|Y|Z> <Number>")
minetest.chat_send_player(name, "Incorrect usage. <X|Y|Z> <Number>") return false
end end
if not tonumber(args[2]) then local args = param:split(" ")
return false, "Not a Number!" if #args < 2 then
end minetest.chat_send_player(player, "Usage. <X|Y|Z> <Number>")
return false
end
if args[1] == "x" then if not tonumber(args[2]) then
currPos["x"] = currPos["x"] + tonumber(args[2]) return false, "Not a Number!"
minetest.get_player_by_name(name):setpos(currPos) end
minetest.sound_play("whoosh", {pos = target_coords, gain = 0.5, max_hear_distance = 10})
parti2(target_coords) -- Initially generate the target coords from the player's current position (since it's relative) and then perform the math.
elseif args[1] == "y" then local target_coords = minetest.get_player_by_name(name):getpos()
currPos["y"] = currPos["y"] + tonumber(args[2]) if args[1] == "x" then
minetest.get_player_by_name(name):setpos(currPos) target_coords["x"] = target_coords["x"] + tonumber(args[2])
minetest.sound_play("whoosh", {pos = target_coords, gain = 0.5, max_hear_distance = 10}) pname:setpos(find_free_position_near(target_coords))
parti2(target_coords) minetest.sound_play("whoosh", {pos = target_coords, gain = 0.5, max_hear_distance = 10})
elseif args[1] == "z" then parti2(target_coords)
currPos["z"] = currPos["z"] + tonumber(args[2]) elseif args[1] == "y" then
minetest.get_player_by_name(name):setpos(currPos) target_coords["y"] = target_coords["y"] + tonumber(args[2])
minetest.sound_play("whoosh", {pos = target_coords, gain = 0.5, max_hear_distance = 10}) pname:setpos(find_free_position_near(target_coords))
parti2(target_coords) minetest.sound_play("whoosh", {pos = target_coords, gain = 0.5, max_hear_distance = 10})
else parti2(target_coords)
minetest.chat_send_player(name,"Not valid axis") elseif args[1] == "z" then
end target_coords["z"] = target_coords["z"] + tonumber(args[2])
end, pname:setpos(find_free_position_near(target_coords))
}) minetest.sound_play("whoosh", {pos = target_coords, gain = 0.5, max_hear_distance = 10})
parti2(target_coords)
else
minetest.chat_send_player(player,"Not a valid axis. Valid options are X, Y or Z.")
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