diff options
Diffstat (limited to 'teleport_request')
-rw-r--r-- | teleport_request/README.md | 39 | ||||
-rw-r--r-- | teleport_request/init.lua | 89 |
2 files changed, 115 insertions, 13 deletions
diff --git a/teleport_request/README.md b/teleport_request/README.md index 2458f3e..ef13230 100644 --- a/teleport_request/README.md +++ b/teleport_request/README.md @@ -4,32 +4,51 @@ [The Pixel Shadow](https://minetest.tv/) Minetest game servers have switched from "teleport" to "teleport request" via the *tps_teleport* mod. This mod makes it so players must send a request to another player in order to teleport to them. Before they will be allowed to do so, the player must accept the request. This prevents malicious users from teleporting to players' private areas without their permission. It also enhances the overall privacy of our services since if denied teleport, a player must instead travel to the area and "use the front door" so to speak... which might be a locked iron door. ##Privileges: -- *interact* Permits use of all tps_teleport commands -- *tp_admin* Admin priv allows admin to teleport anywhere without permission +- **interact** Permits use of /tpr and /tphr +- **tp_tpc** Permits use of /tpc +- **tp_admin** Admin priv allows admin to teleport anywhere without permission Players may also teleport to coordinates, however if the area is protected, the teleport will be denied. ##Usage: ``` /tpr [playername] ``` -Requests permission to teleport to another player, where [playername] is their exact name. +- **Description:** Requests permission to teleport to another player, where [playername] is their exact name. +- **Required Privilege:** interact +- **Example Usage:** */tpr RobbieF* - requests permission from RobbieF to teleport to them. +- **Notes:** Usernames are case-sensitive. ``` /tphr [playername] ``` -Request permission to teleport another player to you. +- **Description:** Request permission to teleport another player to you. +- **Required Privilege:** interact +- **Example Usage:** /tphr RobbieF - requests RobbieF to teleport to you. +- **Notes:** Usernames are case-sensitive. ``` /tpc [x,y,z] ``` -Teleport to coordinates. Honors area protection: if the area is protected, it must be owned by you in order to teleport to it. +- **Description:** Teleport to coordinates. +- **Required Privilege:** interact, tp_tpc +- **Notes:** Honors area protection: if the area is protected, it must be owned by you in order to teleport to it. + +``` /tpj [axis] [distance] ``` +- **Description:** Teleport a specified distance along a single specified axis. Useful for fast evading. +- **Required Privilege:** interact +- **Available Options for *axis*:** x, y, z +- **Example Usage:** '/tpj y 10' - teleport 10 nodes into the air. ``` /tpy ``` -Accept a user's request to teleport to you or teleport you to them. +- **Description:** Accept a user's request to teleport to you or teleport you to them. ``` /tpn ``` -Deny a user's request to teleport to youor teleport you to them. +- **Description:** Deny a user's request to teleport to youor teleport you to them. + +###Please Note: +Players with the 'tp_admin' privilege override all the required privileges above, except 'interact'. ##Contributors: - [RobbieF](https://minetest.tv) | [GitHub](https://github.com/Cat5TV) - [DonBatman](https://github.com/donbatman) - [NathanS21](http://nathansalapat.com/) +- [ChaosWormz](https://github.com/ChaosWormz) - [Traxie21](https://github.com/Traxie21) The original creater of this mod - All those who contributed to the original mod (please see init.lua) @@ -39,7 +58,9 @@ Deny a user's request to teleport to youor teleport you to them. - Make it so tp_admin priv also overrides need for player to accept /tpr or /tphr - Assess value in changing all tpr-based chat commands to one global command such as /tp to reduce the chance of confusion between tps_admin and the original mod (and also make it so people don't have to remember so many commands). - Create a better sound effect for teleport and apply it to all teleport methods (not just /tpc) -- Creation of "evade" command /tpe which spawns the player in several random locations nearby before placing them at a final destination ~20 nodes away. For evading attack. - Add a handful of coordinates which can be set in config and teleported to by anyone regardless of their protection status (eg., Spawn). - Add a privilege which is required in order to use all commands. I haven't added such a thing since it hasn't been needed on our servers, but I imagine it would be useful on other servers who desire to grant these features only to specific players. -- Enhance privileges: Make /tpc require a separate privilege than the /tpr or /tphr commands. +- Create a new function for the actual setpos() to remove all the redundant code each time the player is moved and the sound played. +- Rewrite to place all chat commands into one single command much like how /teleport works. +- Add a [different] sound effect at the source coords when a TP takes place (so other players hear it when to teleport away). +- Make evade respect land: no teleporting inside land, but instead make sure player is standing on surface or in water. diff --git a/teleport_request/init.lua b/teleport_request/init.lua index e57b592..721939d 100644 --- a/teleport_request/init.lua +++ b/teleport_request/init.lua @@ -5,7 +5,7 @@ local timeout_delay = 60
-local version = "1.3"
+local version = "1.5"
local tpr_list = {}
local tphr_list = {}
@@ -64,8 +64,8 @@ local function tpr_send(sender, receiver) return
end
- --If paremeter is valid, Send teleport message and set the table.
if not minetest.get_player_by_name(receiver) then
+ minetest.chat_send_player(sender, "There is no player by that name. Keep in mind this is case sensitive, and the player must be online.")
return
end
@@ -88,8 +88,8 @@ local function tphr_send(sender, receiver) return
end
- --If paremeter is valid, Send teleport message and set the table.
if not minetest.get_player_by_name(receiver) then
+ minetest.chat_send_player(sender, "There is no player by that name. Keep in mind this is case sensitive, and the player must be online.")
return
end
@@ -212,6 +212,74 @@ local function tpr_accept(name, param) parti2(target_coords)
end
+-- Teleport Jump - Relative Position Teleportation by number of nodes
+local function tpj(player,param)
+ local pname = minetest.get_player_by_name(player)
+
+ if param == "" then
+ minetest.chat_send_player(player, "Usage. <X|Y|Z> <Number>")
+ return false
+ end
+
+ local args = param:split(" ") -- look into this. Can it crash if the player does not have two parameters?
+ if #args < 2 then
+ minetest.chat_send_player(player, "Usage. <X|Y|Z> <Number>")
+ return false
+ end
+
+ if not tonumber(args[2]) then
+ return false, "Not a Number!"
+ 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(player):getpos()
+ if args[1] == "x" then
+ target_coords["x"] = target_coords["x"] + tonumber(args[2])
+ 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)
+ elseif args[1] == "y" then
+ target_coords["y"] = target_coords["y"] + tonumber(args[2])
+ 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)
+ elseif args[1] == "z" then
+ target_coords["z"] = target_coords["z"] + tonumber(args[2])
+ 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
+
+-- Evade
+local function tpe(player)
+ minetest.chat_send_player(player, "EVADE!")
+ local mindistance = 15
+ local maxdistance = 50
+ local times = math.random(6,20) -- how many times to jump - minimum,maximum
+ local negatives = { '-','' } -- either it's this way or that way: the difference between -10 and 10
+ local options = { 'x', 'y', 'z' }
+ local isnegative = ''
+ local distance = 0
+ local axis = ''
+ local iteration = 0
+ for i = 1,times do
+ -- do this every 1 second
+ minetest.after(iteration,
+ function()
+ isnegative = negatives[math.random(2)] -- choose randomly whether this is this way or that
+ distance = isnegative .. math.random(mindistance,maxdistance) -- the distance to jump
+ axis = options[math.random(3)]
+ local command = axis .. " " .. distance
+ tpj(player,command)
+ end
+ )
+ iteration = iteration + 0.5
+ end
+end
+
minetest.register_chatcommand("tpr", {
description = "Request teleport to another player",
params = "<playername> | leave playername empty to see help message",
@@ -229,10 +297,23 @@ minetest.register_chatcommand("tphr", { minetest.register_chatcommand("tpc", {
description = "Teleport to coordinates",
params = "<coordinates> | leave coordinates empty to see help message",
- privs = {interact=true},
+ privs = {interact=true,tp_tpc=true},
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("tpe", {
+ description = "Evade Enemy",
+ privs = {interact=true},
+ func = tpe
+})
+
minetest.register_chatcommand("tpy", {
description = "Accept teleport requests from another player",
func = tpr_accept
|