From 5207e67e800b107c75ddf44406ba8e57506cffb4 Mon Sep 17 00:00:00 2001 From: Robbie Ferguson Date: Tue, 17 May 2016 13:45:22 -0400 Subject: [PATCH 01/29] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 2458f3e..c0c507c 100644 --- a/README.md +++ b/README.md @@ -43,3 +43,4 @@ Deny a user's request to teleport to youor teleport you to them. - 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. +- Merge [ChaosWormz mt_reletive_teleportation mod](https://github.com/ChaosWormz/mt_reletive_teleportation) into tps_teleport. From c18ee77a4792be40061f379bdb767de33f13cf2c Mon Sep 17 00:00:00 2001 From: Robbie Ferguson Date: Tue, 17 May 2016 14:00:19 -0400 Subject: [PATCH 02/29] Add new priv. --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c0c507c..b2a56ed 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,8 @@ [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 +- *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. From 86bec396aef7ac3eb9fb6189b91eaaa067bb779f Mon Sep 17 00:00:00 2001 From: Robbie Ferguson Date: Tue, 17 May 2016 14:01:19 -0400 Subject: [PATCH 03/29] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b2a56ed..24dd8bc 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ Deny a user's request to teleport to youor teleport you to them. - [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) @@ -43,5 +44,4 @@ Deny a user's request to teleport to youor teleport you to them. - 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. - Merge [ChaosWormz mt_reletive_teleportation mod](https://github.com/ChaosWormz/mt_reletive_teleportation) into tps_teleport. From a17658174f62b60ee202c4b3809ebb6083ed696a Mon Sep 17 00:00:00 2001 From: Robbie Ferguson Date: Wed, 18 May 2016 07:16:48 -0400 Subject: [PATCH 04/29] Add /tpj From ChaosWormz "mt_reletive_teleportation" mod (typo his). --- init.lua | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/init.lua b/init.lua index e57b592..b38ec0b 100644 --- a/init.lua +++ b/init.lua @@ -212,6 +212,47 @@ local function tpr_accept(name, param) parti2(target_coords) end +minetest.register_chatcommand("tpj", { + params = " ", + description = "Relative Teleportation", + 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. ") + return false + end + + local args = param:split(" ") + if #args < 2 then + minetest.chat_send_player(name, "Incorrect usage. ") + end + + if not tonumber(args[2]) then + return false, "Not a Number!" + end + + if args[1] == "x" then + currPos["x"] = currPos["x"] + tonumber(args[2]) + minetest.get_player_by_name(name):setpos(currPos) + minetest.sound_play("whoosh", {pos = target_coords, gain = 0.5, max_hear_distance = 10}) + parti2(target_coords) + elseif args[1] == "y" then + currPos["y"] = currPos["y"] + tonumber(args[2]) + minetest.get_player_by_name(name):setpos(currPos) + minetest.sound_play("whoosh", {pos = target_coords, gain = 0.5, max_hear_distance = 10}) + parti2(target_coords) + elseif args[1] == "z" then + currPos["z"] = currPos["z"] + tonumber(args[2]) + minetest.get_player_by_name(name):setpos(currPos) + minetest.sound_play("whoosh", {pos = target_coords, gain = 0.5, max_hear_distance = 10}) + parti2(target_coords) + else + minetest.chat_send_player(name,"Not valid axis") + end + end, +}) + minetest.register_chatcommand("tpr", { description = "Request teleport to another player", params = " | leave playername empty to see help message", From a23aad4334885866fd658152e68f0a2a75d5f078 Mon Sep 17 00:00:00 2001 From: Robbie Ferguson Date: Wed, 18 May 2016 07:26:52 -0400 Subject: [PATCH 05/29] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 24dd8bc..de027f1 100644 --- a/README.md +++ b/README.md @@ -44,4 +44,4 @@ Deny a user's request to teleport to youor teleport you to them. - 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. -- Merge [ChaosWormz mt_reletive_teleportation mod](https://github.com/ChaosWormz/mt_reletive_teleportation) into tps_teleport. +- Create a new function for the actual setpos() to remove all the redundant code each time the player is moved and the sound played. From 9af1969f376f1f71c14e2b3f71a1bf1494c9423a Mon Sep 17 00:00:00 2001 From: Robbie Ferguson Date: Wed, 18 May 2016 07:28:24 -0400 Subject: [PATCH 06/29] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index de027f1..80f0f6c 100644 --- a/README.md +++ b/README.md @@ -45,3 +45,4 @@ Deny a user's request to teleport to youor teleport you to them. - 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. - 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. From 9778db42687ae6eeadb842251aeb25c903e5308d Mon Sep 17 00:00:00 2001 From: Robbie Ferguson Date: Wed, 18 May 2016 07:40:42 -0400 Subject: [PATCH 07/29] Make /tpj require interact priv and recode /tpj Also make it so Minetest checks for the tp_tpc priv rather than our function. --- init.lua | 89 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 48 insertions(+), 41 deletions(-) diff --git a/init.lua b/init.lua index b38ec0b..5e5f6b7 100644 --- a/init.lua +++ b/init.lua @@ -212,46 +212,46 @@ local function tpr_accept(name, param) parti2(target_coords) end -minetest.register_chatcommand("tpj", { - params = " ", - description = "Relative Teleportation", - 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. ") - return false - end - - local args = param:split(" ") - if #args < 2 then - minetest.chat_send_player(name, "Incorrect usage. ") - end - - if not tonumber(args[2]) then - return false, "Not a Number!" - end - - if args[1] == "x" then - currPos["x"] = currPos["x"] + tonumber(args[2]) - minetest.get_player_by_name(name):setpos(currPos) - minetest.sound_play("whoosh", {pos = target_coords, gain = 0.5, max_hear_distance = 10}) - parti2(target_coords) - elseif args[1] == "y" then - currPos["y"] = currPos["y"] + tonumber(args[2]) - minetest.get_player_by_name(name):setpos(currPos) - minetest.sound_play("whoosh", {pos = target_coords, gain = 0.5, max_hear_distance = 10}) - parti2(target_coords) - elseif args[1] == "z" then - currPos["z"] = currPos["z"] + tonumber(args[2]) - minetest.get_player_by_name(name):setpos(currPos) - minetest.sound_play("whoosh", {pos = target_coords, gain = 0.5, max_hear_distance = 10}) - parti2(target_coords) - else - minetest.chat_send_player(name,"Not valid axis") - end - end, -}) +-- Teleport Jump - Relative Position Teleportation by number of nodes +local function tpj(name,param) + local pname = minetest.get_player_by_name(player) + + if param == "" then + minetest.chat_send_player(player, "Usage. ") + return false + end + + local args = param:split(" ") + if #args < 2 then + minetest.chat_send_player(player, "Usage. ") + 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(name):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 minetest.register_chatcommand("tpr", { description = "Request teleport to another player", @@ -270,10 +270,17 @@ minetest.register_chatcommand("tphr", { minetest.register_chatcommand("tpc", { description = "Teleport to coordinates", params = " | 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 = " | leave empty to see help message", + privs = {interact=true}, + func = tpj +}) + minetest.register_chatcommand("tpy", { description = "Accept teleport requests from another player", func = tpr_accept From 4964bf1de7074bba37f4f97bd198dc090c291916 Mon Sep 17 00:00:00 2001 From: Robbie Ferguson Date: Wed, 18 May 2016 07:41:39 -0400 Subject: [PATCH 08/29] Increase version to 1.4 So much development has gone into it so far so I think it warrants a tick on the increment clock :) --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 5e5f6b7..acc87ca 100644 --- a/init.lua +++ b/init.lua @@ -5,7 +5,7 @@ local timeout_delay = 60 -local version = "1.3" +local version = "1.4" local tpr_list = {} local tphr_list = {} From 89b1021275f4078ce2b92bf04efedb9d683312b5 Mon Sep 17 00:00:00 2001 From: Robbie Ferguson Date: Wed, 18 May 2016 07:43:47 -0400 Subject: [PATCH 09/29] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 80f0f6c..fdf3aae 100644 --- a/README.md +++ b/README.md @@ -46,3 +46,4 @@ Deny a user's request to teleport to youor teleport you to them. - 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. - 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). From 55a86adc760760692777741cc2d0bdd638979918 Mon Sep 17 00:00:00 2001 From: Robbie Ferguson Date: Wed, 18 May 2016 07:49:07 -0400 Subject: [PATCH 10/29] Minor improvements to the UX. --- init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index acc87ca..2490ac4 100644 --- a/init.lua +++ b/init.lua @@ -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 From 05ad95f474bbbb643db85382caf68e8846c9ce9d Mon Sep 17 00:00:00 2001 From: Robbie Ferguson Date: Wed, 18 May 2016 11:42:47 -0400 Subject: [PATCH 11/29] Add /tpj and usage examples. --- README.md | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index fdf3aae..b7f481d 100644 --- a/README.md +++ b/README.md @@ -13,19 +13,36 @@ Players may also teleport to coordinates, however if the area is protected, the ##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) From 8aef7c2ec7d1fada96075e618dc7e12fa9a778cd Mon Sep 17 00:00:00 2001 From: Robbie Ferguson Date: Wed, 18 May 2016 11:43:52 -0400 Subject: [PATCH 12/29] Update README.md --- README.md | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index b7f481d..b5f4d38 100644 --- a/README.md +++ b/README.md @@ -13,33 +13,33 @@ Players may also teleport to coordinates, however if the area is protected, the ##Usage: ``` /tpr [playername] ``` -*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. +- *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] ``` -*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. +- *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] ``` -*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. +- *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. +- *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 ``` -*Description:* 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 ``` -*Description:* 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'. From e2483592e5f3a987def19fa1d7b365aaf87f2f43 Mon Sep 17 00:00:00 2001 From: Robbie Ferguson Date: Wed, 18 May 2016 11:51:16 -0400 Subject: [PATCH 13/29] Fix my markdown Silly n00b! --- README.md | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index b5f4d38..61db056 100644 --- a/README.md +++ b/README.md @@ -4,42 +4,42 @@ [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 /tpr and /tphr -- *tp_tpc* Permits use of /tpc -- *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] ``` -- *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. +- **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] ``` -- *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. +- **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] ``` -- *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. +- **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. +- **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 ``` -- *Description:* 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 ``` -- *Description:* 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'. From 2f82b11d9c912486473c7a685ae710745af9aad0 Mon Sep 17 00:00:00 2001 From: Robbie Ferguson Date: Wed, 18 May 2016 15:10:23 -0400 Subject: [PATCH 14/29] Add /tpe hehe --- init.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/init.lua b/init.lua index 2490ac4..f091a83 100644 --- a/init.lua +++ b/init.lua @@ -253,6 +253,19 @@ local function tpj(name,param) end end +-- Evade +local function tpe(name) + local negatives = { '-','' } -- either it's this way or that way + local isnegative = negatives[math.random(2)] + local distance = negatives .. math.random(4,15) -- the distance to jump + local times = math.random(3,6) -- how many times to jump - minimum,maximum + local options = { 'x', 'y', 'z' } + local axis = options[math.random(3)] + for i = 1,times do + minetest.after(1, tpj(axis,distance)) -- do this every 1 second + end +end + minetest.register_chatcommand("tpr", { description = "Request teleport to another player", params = " | leave playername empty to see help message", @@ -281,6 +294,12 @@ minetest.register_chatcommand("tpj", { 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 From a601838eba24b7f23da18d45274b9f1ad49d0fef Mon Sep 17 00:00:00 2001 From: Robbie Ferguson Date: Wed, 18 May 2016 15:29:35 -0400 Subject: [PATCH 15/29] Fix negative distances --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index f091a83..866bd0c 100644 --- a/init.lua +++ b/init.lua @@ -257,7 +257,7 @@ end local function tpe(name) local negatives = { '-','' } -- either it's this way or that way local isnegative = negatives[math.random(2)] - local distance = negatives .. math.random(4,15) -- the distance to jump + local distance = isnegative .. math.random(4,15) -- the distance to jump local times = math.random(3,6) -- how many times to jump - minimum,maximum local options = { 'x', 'y', 'z' } local axis = options[math.random(3)] From aa537a6765aedfd40d7e4fd4a19cc1ea0684e5a2 Mon Sep 17 00:00:00 2001 From: Robbie Ferguson Date: Wed, 18 May 2016 15:35:25 -0400 Subject: [PATCH 16/29] Update init.lua --- init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 866bd0c..ffec348 100644 --- a/init.lua +++ b/init.lua @@ -213,7 +213,7 @@ local function tpr_accept(name, param) end -- Teleport Jump - Relative Position Teleportation by number of nodes -local function tpj(name,param) +local function tpj(player,param) local pname = minetest.get_player_by_name(player) if param == "" then @@ -254,7 +254,7 @@ local function tpj(name,param) end -- Evade -local function tpe(name) +local function tpe(player) local negatives = { '-','' } -- either it's this way or that way local isnegative = negatives[math.random(2)] local distance = isnegative .. math.random(4,15) -- the distance to jump From acf96587329c2936bf3b0ff93d442a211fff7a38 Mon Sep 17 00:00:00 2001 From: Robbie Ferguson Date: Wed, 18 May 2016 15:44:25 -0400 Subject: [PATCH 17/29] n00b coder repair --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index ffec348..de98c23 100644 --- a/init.lua +++ b/init.lua @@ -262,7 +262,7 @@ local function tpe(player) local options = { 'x', 'y', 'z' } local axis = options[math.random(3)] for i = 1,times do - minetest.after(1, tpj(axis,distance)) -- do this every 1 second + minetest.after(1, function() tpj(axis,distance) ) -- do this every 1 second end end From a3d18f5a70de52655e20fb74b4e419ffa97804c2 Mon Sep 17 00:00:00 2001 From: Robbie Ferguson Date: Wed, 18 May 2016 15:48:04 -0400 Subject: [PATCH 18/29] Look, I'm learning! --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index de98c23..4e66939 100644 --- a/init.lua +++ b/init.lua @@ -262,7 +262,7 @@ local function tpe(player) local options = { 'x', 'y', 'z' } local axis = options[math.random(3)] for i = 1,times do - minetest.after(1, function() tpj(axis,distance) ) -- do this every 1 second + minetest.after(1, function() tpj(axis,distance) end) -- do this every 1 second end end From 0e0eb50206aafe202fc614477d31520bca1380a9 Mon Sep 17 00:00:00 2001 From: Robbie Ferguson Date: Wed, 18 May 2016 15:55:38 -0400 Subject: [PATCH 19/29] Update init.lua --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 4e66939..fd0566b 100644 --- a/init.lua +++ b/init.lua @@ -232,7 +232,7 @@ local function tpj(player,param) 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() + 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)) From 38982dadf22c2e7e249bd31a8ebf68c2c0a5136f Mon Sep 17 00:00:00 2001 From: Robbie Ferguson Date: Wed, 18 May 2016 16:31:08 -0400 Subject: [PATCH 20/29] Fix the /tpe loop --- init.lua | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/init.lua b/init.lua index fd0566b..f454604 100644 --- a/init.lua +++ b/init.lua @@ -256,13 +256,24 @@ end -- Evade local function tpe(player) local negatives = { '-','' } -- either it's this way or that way - local isnegative = negatives[math.random(2)] - local distance = isnegative .. math.random(4,15) -- the distance to jump - local times = math.random(3,6) -- how many times to jump - minimum,maximum local options = { 'x', 'y', 'z' } - local axis = options[math.random(3)] + local mindistance = 4 + local maxdistance = 15 + local isnegative = '' + local distance = 0 + local times = 0 + local axis = '' for i = 1,times do - minetest.after(1, function() tpj(axis,distance) end) -- do this every 1 second + -- do this every 1 second + minetest.after(1, + function() + isnegative = negatives[math.random(2)] + distance = isnegative .. math.random(mindistance,maxdistance) -- the distance to jump + times = math.random(3,6) -- how many times to jump - minimum,maximum + axis = options[math.random(3)] + tpj(axis,distance) + end + ) end end From 97437c3a80c63b91079b82f153e1922f45f46816 Mon Sep 17 00:00:00 2001 From: Robbie Ferguson Date: Wed, 18 May 2016 16:48:43 -0400 Subject: [PATCH 21/29] Update init.lua --- init.lua | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/init.lua b/init.lua index f454604..7603b7c 100644 --- a/init.lua +++ b/init.lua @@ -255,21 +255,20 @@ end -- Evade local function tpe(player) - local negatives = { '-','' } -- either it's this way or that way - local options = { 'x', 'y', 'z' } local mindistance = 4 local maxdistance = 15 + local times = math.random(3,6) -- how many times to jump - minimum,maximum + local negatives = { '-','' } -- either it's this way or that way + local options = { 'x', 'y', 'z' } local isnegative = '' local distance = 0 - local times = 0 local axis = '' for i = 1,times do -- do this every 1 second minetest.after(1, function() - isnegative = negatives[math.random(2)] + isnegative = negatives[math.random(2)] -- choose randomly whether this is this way or that distance = isnegative .. math.random(mindistance,maxdistance) -- the distance to jump - times = math.random(3,6) -- how many times to jump - minimum,maximum axis = options[math.random(3)] tpj(axis,distance) end From 0829e02c19a6de3f888195631b50c9b66dda5ba6 Mon Sep 17 00:00:00 2001 From: Robbie Ferguson Date: Wed, 18 May 2016 17:10:58 -0400 Subject: [PATCH 22/29] Make it go! --- init.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 7603b7c..eb8a754 100644 --- a/init.lua +++ b/init.lua @@ -258,11 +258,12 @@ local function tpe(player) local mindistance = 4 local maxdistance = 15 local times = math.random(3,6) -- how many times to jump - minimum,maximum - local negatives = { '-','' } -- either it's this way or that way + 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 param = {} for i = 1,times do -- do this every 1 second minetest.after(1, @@ -270,7 +271,8 @@ local function tpe(player) 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)] - tpj(axis,distance) + param = axis .. distance + tpj(param) end ) end From 30718b325f93f32572af162bd730a328477a2cb7 Mon Sep 17 00:00:00 2001 From: Robbie Ferguson Date: Wed, 18 May 2016 17:17:05 -0400 Subject: [PATCH 23/29] Update init.lua --- init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index eb8a754..d62161d 100644 --- a/init.lua +++ b/init.lua @@ -221,7 +221,7 @@ local function tpj(player,param) return false end - local args = param:split(" ") + 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. ") return false @@ -271,7 +271,7 @@ local function tpe(player) 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)] - param = axis .. distance + param = axis .. " " .. distance tpj(param) end ) From b2ce7f38b09b1e9d95bfdd4e25344e4ed1adcfbf Mon Sep 17 00:00:00 2001 From: Robbie Ferguson Date: Wed, 18 May 2016 18:01:39 -0400 Subject: [PATCH 24/29] Testing --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index d62161d..d2f0a93 100644 --- a/init.lua +++ b/init.lua @@ -215,7 +215,7 @@ end -- Teleport Jump - Relative Position Teleportation by number of nodes local function tpj(player,param) local pname = minetest.get_player_by_name(player) - + print param if param == "" then minetest.chat_send_player(player, "Usage. ") return false From 6c21a250c6c8e6daba2fea10864dad4ff79212da Mon Sep 17 00:00:00 2001 From: Robbie Ferguson Date: Wed, 18 May 2016 18:04:40 -0400 Subject: [PATCH 25/29] Update init.lua --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index d2f0a93..d62161d 100644 --- a/init.lua +++ b/init.lua @@ -215,7 +215,7 @@ end -- Teleport Jump - Relative Position Teleportation by number of nodes local function tpj(player,param) local pname = minetest.get_player_by_name(player) - print param + if param == "" then minetest.chat_send_player(player, "Usage. ") return false From a505e92faab943b1a19ae7c6a76f5a680b748982 Mon Sep 17 00:00:00 2001 From: Robbie Ferguson Date: Wed, 18 May 2016 18:47:49 -0400 Subject: [PATCH 26/29] Version 1.5 Now with a version of /tpe that will make your mind explode instead of your server. --- init.lua | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/init.lua b/init.lua index d62161d..d201d99 100644 --- a/init.lua +++ b/init.lua @@ -5,7 +5,7 @@ local timeout_delay = 60 -local version = "1.4" +local version = "1.5" local tpr_list = {} local tphr_list = {} @@ -215,12 +215,12 @@ 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. ") 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. ") @@ -257,24 +257,25 @@ end local function tpe(player) local mindistance = 4 local maxdistance = 15 - local times = math.random(3,6) -- how many times to jump - minimum,maximum + 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 param = {} + local iteration = 0.5 for i = 1,times do -- do this every 1 second - minetest.after(1, + 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)] - param = axis .. " " .. distance - tpj(param) + local command = axis .. " " .. distance + tpj(player,command) end ) + iteration = iteration + 0.5 end end From 704bc994e1cf8154a84dc1c8e47cff347c0e0bbe Mon Sep 17 00:00:00 2001 From: Robbie Ferguson Date: Wed, 18 May 2016 18:52:26 -0400 Subject: [PATCH 27/29] Evade should be working perfectly now. Only thing left to do is make it so it doesn't spawn you inside rocks! For now you can to /tpj y 20 to recover ;) --- init.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index d201d99..5f28c79 100644 --- a/init.lua +++ b/init.lua @@ -255,6 +255,7 @@ end -- Evade local function tpe(player) + minetest.chat_send_player(sender, "EVADE!") local mindistance = 4 local maxdistance = 15 local times = math.random(6,20) -- how many times to jump - minimum,maximum @@ -263,7 +264,7 @@ local function tpe(player) local isnegative = '' local distance = 0 local axis = '' - local iteration = 0.5 + local iteration = 0 for i = 1,times do -- do this every 1 second minetest.after(iteration, From ee00f0cf2fb86a97db6ce59faee2239c59f21ebb Mon Sep 17 00:00:00 2001 From: Robbie Ferguson Date: Wed, 18 May 2016 18:55:05 -0400 Subject: [PATCH 28/29] Evade is implemented remove from to do --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 61db056..ef13230 100644 --- a/README.md +++ b/README.md @@ -58,9 +58,9 @@ Players with the 'tp_admin' privilege override all the required privileges above - 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. - 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. From 58b8198de241e54722ab2cd64a1b0c98178f6aa1 Mon Sep 17 00:00:00 2001 From: Robbie Ferguson Date: Wed, 18 May 2016 18:59:28 -0400 Subject: [PATCH 29/29] Minor fix --- init.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index 5f28c79..721939d 100644 --- a/init.lua +++ b/init.lua @@ -255,9 +255,9 @@ end -- Evade local function tpe(player) - minetest.chat_send_player(sender, "EVADE!") - local mindistance = 4 - local maxdistance = 15 + 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' }