Merge pull request #14 from Panquesito7/master

Support for beerchat/chat2
This commit is contained in:
ChaosWormz 2019-08-10 13:09:05 +03:00 committed by GitHub
commit b5a4320c2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 373 additions and 208 deletions

@ -1,53 +1,58 @@
# Teleport Request
[The Pixel Shadow](https://minetest.tv/) Minetest game servers have switched from "teleport" to "teleport request" via the *teleport-request* 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.
A mod that allows players to send a teleport request.
**(See "How to use" below for more information.)**
## Privileges:
Each command needs a privilege. These are the following privileges:
- **tp** is requiered in order to use all commands.
- **tp_tpc** is requiered in order to use "/tpc"
- **tp_tpc** is requiered in order to use "/tpe"
- **tp_tpc** is requiered in order to use "/tpj"
- **tp_tpc** is requiered in order to use `/tpc`
- **tp_tpc** is requiered in order to use `/tpe`
- **tp_tpc** is requiered in order to use `/tpj`
- **interact** is also requiered to use all commands.
**tp_admin** overrides everything: e.g. you can teleport to players even when they haven't decided to accept, or not. You can also teleport him/her to you.
**tp_admin** overrides everything: e.g. you can teleport to players even when they haven't decided to accept, or not. You can also teleport him/her to you (this happens only when `enable_immediate_teleport` is enabled on `config.lua`).
Players can also teleport to coordinates, however, if the area is protected, the teleport will be denied.
## How to use:
Each command does a function. "**Example Usage**" is an example of how to use the command.
Note there must be 2 players in order to make the commands to work: a player must send a request to another player (**see https://wiki.minetest.net/Server or see https://wiki.minetest.net/Setting_up_a_server for more information**).
Note there must be 2 players in order to make the commands to work: a player must send a request to another player (**see https://wiki.minetest.net/Server or see https://wiki.minetest.net/Setting_up_a_server for more information**).
There are two methods of sending a request:
1. A request which teleports you to the specified player (command `/tpr <player>`).
2. A request which teleports the specified player to you (command `/tphr <player>`).
To accept a request some sent you, you must use `/tpy`.
These are the following commands available in-game:
``` /tpr [playername] ```
- **Name:** Teleport Request
- **Description:** Requests permission to teleport to another player, where [playername] is their exact name.
- **Required Privileges:** "interact", "tp"
- **Required Privileges:** `interact, tp`
- **Example Usage:** */tpr RobbieF* - requests permission from RobbieF to teleport to them.
- **Notes:** Usernames are case-sensitive. If you have "tp_admin" privilege, you will immediately teleport to the specificed player.
- **Notes:** Usernames are case-sensitive. If you have "tp_admin" privilege, you will immediately teleport to the specificed player (does not apply if `enable_immediate_teleport` setting is disabled, enabled by default).
``` /tphr [playername] ```
- **Name:** Teleport Here Request
- **Description:** Request permission to teleport another player to you.
- **Required Privileges:** "interact", "tp"
- **Required Privileges:** `interact, tp`
- **Example Usage:** /tphr RobbieF - requests RobbieF to teleport to you.
- **Notes:** Usernames are case-sensitive. If you have "tp_admin" privilege, RobbieF will teleport to you immediately.
- **Notes:** Usernames are case-sensitive. If you have "tp_admin" privilege, RobbieF will teleport to you immediately (does not apply if `enable_immediate_teleport` setting is disabled, enabled by default).
``` /tpc [x,y,z] ```
- **Name:** Teleport to Coordinates
- **Description:** Teleport to coordinates.
- **Required Privileges:** "interact", "tp_tpc", "tp"
- **Notes:** Honors area protection: if the area is protected, it must be owned by you in order to teleport to it, or you must have "areas" privilege in order to teleport to those coordinates (this does not apply if "areas" mod is not detected).
- **Required Privileges:** `interact, tp_tpc, tp`
- **Notes:** Honors area protection: if the area is protected, it must be owned by you in order to teleport to it, or you must have "areas" privilege in order to teleport to those coordinates (this works only when [areas](https://github.com/minetest-mods/areas) is installed).
``` /tpj [axis] [distance] ```
- **Name:** Teleport Jump
- **Description:** Teleport a specified distance along a single specified axis.
- **Required Privilege:** "interact", "tp", "tp_tpc"
- **Required Privilege:** `interact", tp, tp_tpc`
- **Available Options for *axis*:** x, y, z
- **Example Usage:** '/tpj y 10' - teleport 10 nodes into the air.
``` /tpe ```
- **Name:** Teleport Evade
- **Description:** In a sticky situation? Evade your enemy by teleporting to several nearby coordinates in random pattern. There's no knowing where you'll end up.
- **Required Privileges:** "interact", "tp_tpc", "tp"
- **Required Privileges:** `interact, tp_tpc, tp`
- **Example Usage:** '/tpe' - teleports you to a random number of random coordinates in an evasive pattern.
``` /tpy ```
@ -61,6 +66,8 @@ There are no dependencies.
However, optional dependencies are:
- [areas](https://github.com/minetest-mods/areas)
- [intllib](https://github.com/minetest-mods/intllib)
- [beerchat](https://github.com/pandorabox-io/beerchat)
- [chat2](https://github.com/minetest-mods/chat2)
## Requirements
This mod requieres MT/MTG 5.0.0+ to run.
@ -71,7 +78,7 @@ Report bugs or suggest ideas by [creating an issue](https://github.com/ChaosWorm
If you know how to fix an issue, or want something to be added, consider opening a [pull request](https://github.com/ChaosWormz/teleport-request/compare).
## License
LGPL-2.1 for code, CC-BY-SA-4.0 for [media](https://github.com/ChaosWormz/teleport-request/blob/master/sounds/LICENSE.txt) and [textures](https://github.com/ChaosWormz/teleport-request/blob/master/textures/LICENSE.txt) (click [here](https://github.com/ChaosWormz/teleport-request/blob/master/LICENSE.md) for more information).
[LGPL-2.1](https://github.com/ChaosWormz/teleport-request/blob/master/LICENSE.md) for everything.
## Contributors:
- [RobbieF](https://minetest.tv) | [GitHub](https://github.com/Cat5TV)
@ -80,10 +87,27 @@ LGPL-2.1 for code, CC-BY-SA-4.0 for [media](https://github.com/ChaosWormz/telepo
- [ChaosWormz](https://github.com/ChaosWormz)
- [Panquesito7](https://github.com/Panquesito7)
- [coil0](https://github.com/coil0)
- [Zeno-](https://github.com/Zeno-)
- [indriApollo](https://github.com/indriApollo)
- [Billy-S](https://github.com/Billy-S)
- Traxie21, the original creator of this mod (however, he/she does not have a GitHub account anymore).
All those who contributed to the original mod (please see `init.lua`).
## Configuring the mod
Open your `minetest.conf` located in your Minetest directory.
Set the values of the settings you'd like to.
Available options are:
```
tp.timeout_delay = 60
tp.enable_immediate_teleport = true
tp_enable_tpp_command = false
```
Those values are the default values of the mod.
You can also go to your Minetest, Settings tab, All settings, Mods, and you'll find `tpr` there.
Or another way to do it, is changing the values in `settingstypes.txt`.
## Installation
- Unzip the archive, rename the folder to tpr and
place it in ..minetest/mods/
@ -104,3 +128,5 @@ https://wiki.minetest.net/Installing_Mods
- Create a better sound effect for teleport and apply it to all teleport methods (not just /tpc)
- Rewrite to place all chat commands into one single command much like how /teleport works.
- Make evade respect land: no teleporting inside land, but instead make sure player is standing on surface or in water.
If you think something else should be added to this list, [submit an issue](https://github.com/ChaosWormz/teleport-request/issues/new).

@ -24,22 +24,23 @@ local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")
-- Timeout delay and mod version.
timeout_delay = 60
version = "1.5"
tp.timeout_delay = tonumber(minetest.settings:get("tp.timeout_delay")) or 60
tp.version = "1.5"
-- Enable teleporting immediately to the player with "tp_admin" privilege.
enable_immediate_teleport = true
-- Enable teleporting immediately to the specified player for those with "tp_admin" privilege.
tp.enable_immediate_teleport = minetest.settings:get_bool("tp.enable_immediate_teleport")
local chatmsg, source, target, name2, target_coords, pos
-- Set the values of the positions of your places, players will be able to teleport to them (no matter if it is protected, or not).
available_places = {
-- You must activate "enable_tpp_command" in order to make this to work.
tp.available_places = {
spawn = {x = 0, y = 0, z = 0}, -- Set coordinates of spawn here.
shop = {x = 0, y = 0, z = 0}, -- Set coordinates of the shop here.
}
-- Enable tpp command
enable_tpp_command = false
tp.enable_tpp_command = minetest.settings:get_bool("tp.enable_tpp_command")
-- Register privileges
minetest.register_privilege("tp", {

@ -1,2 +0,0 @@
areas?
intllib?

330
init.lua

@ -22,12 +22,14 @@ Originally made by Traxie21 and released with the WTFPL license.
Forum link: https://forum.minetest.net/viewtopic.php?id=4457
Updates by Zeno, Panquesito7 and ChaosWormz.
License: LGPL-2.1 for code, CC-BY-SA-4.0 for media and textures.
License: LGPL-2.1 for everything.
Optional dependencies: areas, intllib
New release by RobbieF under new mod: tps_teleport - http://blog.minetest.tv/teleport-request/
--]]
tp = {}
-- Load support for intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")
@ -35,43 +37,43 @@ local S, NS = dofile(MP.."/intllib.lua")
-- Load configuration.
dofile(MP.."/config.lua")
local tpr_list = {}
local tphr_list = {}
tp.tpr_list = {}
tp.tphr_list = {}
local map_size = 30912
local function can_teleport(to)
function tp.can_teleport(to)
return to.x < map_size and to.x > -map_size and to.y < map_size and to.y > -map_size and to.z < map_size and to.z > -map_size
end
-- Teleport player to a player (used in "/tpr" and in "/tphr" command).
function tpr_teleport_player()
function tp.tpr_teleport_player()
local target_coords = source:get_pos()
local target_sound = target:get_pos()
target:set_pos(find_free_position_near(target_coords))
target:set_pos(tp.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_sound, gain = 0.5, max_hear_distance = 10})
--parti2(target_coords)
--tp.parti2(target_coords)
end
-- TPC & TPJ
function tpc_teleport_player(player)
function tp.tpc_teleport_player(player)
local pname = minetest.get_player_by_name(player)
minetest.sound_play("whoosh", {pos = pname:get_pos(), gain = 0.5, max_hear_distance = 10})
pname:set_pos(find_free_position_near(target_coords))
pname:set_pos(tp.find_free_position_near(target_coords))
minetest.sound_play("whoosh", {pos = target_coords, gain = 0.5, max_hear_distance = 10})
--parti2(target_coords)
--tp.parti2(target_coords)
end
-- TPP
function tpp_teleport_player(player)
function tp.tpp_teleport_player(player)
local pname = minetest.get_player_by_name(player)
minetest.sound_play("whoosh", {pos = pname:get_pos(), gain = 0.5, max_hear_distance = 10})
pname:set_pos(find_free_position_near(pos))
pname:set_pos(tp.find_free_position_near(pos))
minetest.sound_play("whoosh", {pos = pos, gain = 0.5, max_hear_distance = 10})
--parti2(target_coords)
--tp.parti2(target_coords)
end
function find_free_position_near(pos)
function tp.find_free_position_near(pos)
local tries = {
{x=1,y=0,z=0},
{x=-1,y=0,z=0},
@ -87,7 +89,7 @@ function find_free_position_near(pos)
return pos, false
end
function parti(pos)
function tp.parti(pos)
minetest.add_particlespawner(50, 0.4,
{x=pos.x + 0.5, y=pos.y, z=pos.z + 0.5}, {x=pos.x - 0.5, y=pos.y, z=pos.z - 0.5},
{x=0, y=5, z=0}, {x=0, y=0, z=0},
@ -98,7 +100,7 @@ function parti(pos)
"tps_portal_parti.png")
end
function parti2(pos)
function tp.parti2(pos)
minetest.add_particlespawner(50, 0.4,
{x=pos.x + 0.5, y=pos.y + 10, z=pos.z + 0.5}, {x=pos.x - 0.5, y=pos.y, z=pos.z - 0.5},
{x=0, y=-5, z=0}, {x=0, y=0, z=0},
@ -110,117 +112,179 @@ function parti2(pos)
end
-- Teleport Request System
function clear_tpr_list(name)
if tpr_list[name] then
tpr_list[name] = nil
function tp.clear_tpr_list(name)
if tp.tpr_list[name] then
tp.tpr_list[name] = nil
return
end
end
function clear_tphr_list(name)
if tphr_list[name] then
tphr_list[name] = nil
function tp.clear_tphr_list(name)
if tp.tphr_list[name] then
tp.tphr_list[name] = nil
return
end
end
-- Clear requests when the player leaves
minetest.register_on_leaveplayer(function(name)
if tpr_list[name] then
tpr_list[name] = nil
if tp.tpr_list[name] then
tp.tpr_list[name] = nil
return
end
if tphr_list[name] then
tphr_list[name] = nil
if tp.tphr_list[name] then
tp.tphr_list[name] = nil
return
end
end)
function tpr_send(sender, receiver)
if minetest.check_player_privs(sender, {tp_admin = true}) and enable_immediate_teleport then
function tp.tpr_send(sender, receiver)
-- Compatibility with beerchat (UNTESTED)
if minetest.get_modpath("beerchat") and not minetest.check_player_privs(sender, {tp_admin = true}) then
if minetest.get_player_by_name(sender):get_attribute("beerchat:muted:" .. sender) then
minetest.chat_send_player(sender, S("You are not allowed to send requests because you're muted."))
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(sender), S("You are not allowed to send requests because you're muted."), 0xFFFFFF)
end
return
end
end
if minetest.check_player_privs(sender, {tp_admin = true}) and tp.enable_immediate_teleport then
if receiver == "" then
minetest.chat_send_player(sender, S("Usage: /tpr <Player name>"))
return
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(sender), S("Usage: /tpr <Player name>"), 0xFFFFFF)
end
return
end
if not minetest.get_player_by_name(receiver) then
minetest.chat_send_player(sender, S("There is no player by that name. Keep in mind this is case-sensitive, and the player must be online"))
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(sender), S("There is no player by that name. Keep in mind this is case-sensitive, and the player must be online"), 0xFFFFFF)
end
return
end
tpr_list[receiver] = sender
tpr_accept(receiver)
tp.tpr_list[receiver] = sender
tp.tpr_accept(receiver)
minetest.chat_send_player(sender, S("You are teleporting to @1.", receiver))
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(sender), S("You are teleporting to @1.", receiver), 0xFFFFFF)
end
return
end
if receiver == "" then
minetest.chat_send_player(sender, S("Usage: /tpr <Player name>"))
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(sender), S("Usage: /tpr <Player name>"), 0xFFFFFF)
end
return
end
if not minetest.get_player_by_name(receiver) then
minetest.chat_send_player(sender, S("There is no player by that name. Keep in mind this is case-sensitive, and the player must be online."))
minetest.chat_send_player(sender, S("There is no player by that name. Keep in mind this is case-sensitive, and the player must be online"))
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(sender), S("There is no player by that name. Keep in mind this is case-sensitive, and the player must be online"), 0xFFFFFF)
end
return
end
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(receiver), S("@1 is requesting to teleport to you. /tpy to accept", sender), 0xFFFFFF)
chat2.send_message(minetest.get_player_by_name(sender), S("Teleport request sent! It will timeout in @1 seconds", tp.timeout_delay), 0xFFFFFF)
end
minetest.chat_send_player(receiver, S("@1 is requesting to teleport to you. /tpy to accept", sender))
minetest.chat_send_player(sender, S("Teleport request sent! It will timeout in @1 seconds", timeout_delay))
-- Write name values to list and clear old values.
tpr_list[receiver] = sender
tp.tpr_list[receiver] = sender
-- Teleport timeout delay
minetest.after(timeout_delay, function(name)
if tpr_list[name] then
tpr_list[name] = nil
minetest.after(tp.timeout_delay, function(name)
if tp.tpr_list[name] then
tp.tpr_list[name] = nil
minetest.chat_send_player(sender, S("Request timed-out."))
minetest.chat_send_player(receiver, S("Request timed-out."))
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(sender), S("Request timed-out."), 0xFFFFFF)
chat2.send_message(minetest.get_player_by_name(receiver), S("Request timed-out."), 0xFFFFFF)
end
return
end
end, receiver)
end
function tphr_send(sender, receiver)
if minetest.check_player_privs(sender, {tp_admin = true}) and enable_immediate_teleport then
function tp.tphr_send(sender, receiver)
-- Compatibility with beerchat (UNTESTED)
if minetest.get_modpath("beerchat") and not minetest.check_player_privs(sender, {tp_admin = true}) then
if minetest.get_player_by_name(sender):get_attribute("beerchat:muted:" .. sender) then
minetest.chat_send_player(sender, S("You are not allowed to send requests because you're muted."))
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(sender), S("You are not allowed to send requests because you're muted."), 0xFFFFFF)
end
return
end
end
if minetest.check_player_privs(sender, {tp_admin = true}) and tp.enable_immediate_teleport then
if receiver == "" then
minetest.chat_send_player(sender, S("Usage: /tphr <Player name>"))
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(sender), S("Usage. /tphr <Player name>"), 0xFFFFFF)
end
return
end
if not minetest.get_player_by_name(receiver) then
minetest.chat_send_player(sender, S("There is no player by that name. Keep in mind this is case-sensitive, and the player must be online"))
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(sender), S("There is no player by that name. Keep in mind this is case-sensitive, and the player must be online"), 0xFFFFFF)
end
return
end
tphr_list[receiver] = sender
tpr_accept(receiver)
tp.tphr_list[receiver] = sender
tp.tpr_accept(receiver)
minetest.chat_send_player(sender, S("@1 is teleporting to you.", receiver))
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(sender), S("@1 is teleporting to you.", receiver), 0xFFFFFF)
end
return
end
if receiver == "" then
minetest.chat_send_player(sender, S("Usage: /tphr <Player name>"))
minetest.chat_send_player(sender, S("Usage: /tphr <Player name>"))
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(sender), S("Usage. /tphr <Player name>"), 0xFFFFFF)
end
return
end
if not minetest.get_player_by_name(receiver) then
minetest.chat_send_player(sender, S("There is no player by that name. Keep in mind this is case-sensitive, and the player must be online."))
minetest.chat_send_player(sender, S("There is no player by that name. Keep in mind this is case-sensitive, and the player must be online"))
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(sender), S("There is no player by that name. Keep in mind this is case-sensitive, and the player must be online"), 0xFFFFFF)
end
return
end
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(receiver), S("@1 is requesting that you teleport to them. /tpy to accept; /tpn to deny", sender), 0xFFFFFF)
chat2.send_message(minetest.get_player_by_name(sender), S("Teleport request sent! It will timeout in @1 seconds", tp.timeout_delay), 0xFFFFFF)
end
minetest.chat_send_player(receiver, S("@1 is requesting that you teleport to them. /tpy to accept; /tpn to deny", sender))
minetest.chat_send_player(sender, S("Teleport request sent! It will timeout in @1 seconds", timeout_delay))
-- Write name values to list and clear old values.
tphr_list[receiver] = sender
tp.tphr_list[receiver] = sender
-- Teleport timeout delay
minetest.after(timeout_delay, function(name)
if tphr_list[name] then
tphr_list[name] = nil
minetest.after(tp.timeout_delay, function(name)
if tp.tphr_list[name] then
tp.tphr_list[name] = nil
minetest.chat_send_player(sender, S("Request timed-out."))
minetest.chat_send_player(receiver, S("Request timed-out."))
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(sender), S("Request timed-out"), 0xFFFFFF)
chat2.send_message(minetest.get_player_by_name(receiver), S("Request timed-out"), 0xFFFFFF)
end
return
end
end, receiver)
end
function tpc_send(player, coordinates)
function tp.tpc_send(player, coordinates)
local posx,posy,posz = string.match(coordinates, "^(-?%d+), (-?%d+), (-?%d+)$")
local pname = minetest.get_player_by_name(player)
@ -233,22 +297,31 @@ function tpc_send(player, coordinates)
if posx==nil or posy==nil or posz==nil or string.len(posx) > 6 or string.len(posy) > 6 or string.len(posz) > 6 then
minetest.chat_send_player(player, S("Usage: /tpc <x, y, z>"))
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(player), S("Usage: /tpc <x, y, z>"), 0xFFFFFF)
end
return nil
end
target_coords = {x=posx, y=posy, z=posz}
if can_teleport(target_coords) == false then
if tp.can_teleport(target_coords) == false then
minetest.chat_send_player(player, S("You cannot teleport to a location outside the map!"))
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(player), S("You cannot teleport to a location outside the map!"), 0xFFFFFF)
end
return nil
end
-- 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.
-- Admin user (priv "tp_admin") overrides all protection
if minetest.check_player_privs(pname, {tp_admin=true}) then
tpc_teleport_player(player)
if minetest.check_player_privs(pname, {tp_admin = true}) then
tp.tpc_teleport_player(player)
minetest.chat_send_player(player, S("Teleporting to: @1, @2, @3", posx, posy, posz))
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(player), S("Teleporting to: @1, @2, @3", posx, posy, posz), 0xFFFFFF)
end
else
if minetest.check_player_privs(pname, {tp_tpc = true}) then
local protected = minetest.is_protected(target_coords,pname)
@ -256,84 +329,116 @@ function tpc_send(player, coordinates)
if not areas:canInteract(target_coords, player) then
local owners = areas:getNodeOwners(target_coords)
minetest.chat_send_player(player, S("Error: @1 is protected by @2.", minetest.pos_to_string(target_coords), table.concat(owners, ", ")))
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(player), S("Error: @1 is protected by @2.", minetest.pos_to_string(target_coords), table.concat(owners, ", ")), 0xFFFFFF)
end
return
end
end
tpc_teleport_player(player)
tp.tpc_teleport_player(player)
minetest.chat_send_player(player, S("Teleporting to: @1, @2, @3", posx, posy, posz))
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(player), S("Teleporting to: @1, @2, @3", posx, posy, posz), 0xFFFFFF)
end
else
minetest.chat_send_player(player, S("Error: You do not have permission to teleport to coordinates."))
minetest.chat_send_player(player, S("Error: You do not have permission to teleport to those coordinates."))
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(player), S("Error: You do not have permission to teleport to those coordinates."), 0xFFFFFF)
end
return
end
end
end
function tpr_deny(name)
if tpr_list[name] then
name2 = tpr_list[name]
function tp.tpr_deny(name)
if tp.tpr_list[name] then
name2 = tp.tpr_list[name]
minetest.chat_send_player(name2, S("Teleport request denied."))
minetest.chat_send_player(name, S("You denied the request @1 sent you.", name2))
tpr_list[name] = nil
elseif tphr_list[name] then
name2 = tphr_list[name]
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(name2), S("Teleport request denied."), 0xFFFFFF)
chat2.send_message(minetest.get_player_by_name(name), S("You denied the request @1 sent you.", name2), 0xFFFFFF)
end
tp.tpr_list[name] = nil
elseif tp.tphr_list[name] then
name2 = tp.tphr_list[name]
minetest.chat_send_player(name2, S("Teleport request denied."))
minetest.chat_send_player(name, S("You denied the request @1 sent you.", name2))
tphr_list[name] = nil
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(name2), S("Teleport request denied."), 0xFFFFFF)
chat2.send_message(minetest.get_player_by_name(name), S("You denied the request @1 sent you.", name2), 0xFFFFFF)
end
tp.tphr_list[name] = nil
else
minetest.chat_send_player(name, S("Usage: /tpn allows you to deny teleport requests sent to you by other players."))
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(name), S("Usage: /tpn allows you to deny teleport requests sent to you by other players."), 0xFFFFFF)
end
return
end
end
-- Teleport Accept Systems
function tpr_accept(name, param)
function tp.tpr_accept(name, param)
-- Check to prevent constant teleporting.
if not tpr_list[name]
and not tphr_list[name] then
if not tp.tpr_list[name]
and not tp.tphr_list[name]
minetest.chat_send_player(name, S("Usage: /tpy allows you to accept teleport requests sent to you by other players"))
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(name), S("Usage: /tpy allows you to accept teleport requests sent to you by other players"), 0xFFFFFF)
end
return
end
if tpr_list[name] then
name2 = tpr_list[name]
if tp.tpr_list[name] then
name2 = tp.tpr_list[name]
source = minetest.get_player_by_name(name)
target = minetest.get_player_by_name(name2)
chatmsg = S("@1 is teleporting to you.", name2)
tpr_list[name] = nil
elseif tphr_list[name] then
name2 = tphr_list[name]
tp.tpr_list[name] = nil
elseif tp.tphr_list[name] then
name2 = tp.tphr_list[name]
source = minetest.get_player_by_name(name2)
target = minetest.get_player_by_name(name)
chatmsg = S("You are teleporting to @1.", name2)
tphr_list[name] = nil
tp.tphr_list[name] = nil
else
return
end
-- Could happen if either player disconnects (or timeout); if so just abort
if not source
or not target then
minetest.chat_send_player(name, S("@1 just disconnected/left (by timeout).", name2))
minetest.chat_send_player(name, S("@1 doesn't exist, or just disconnected/left (by timeout).", name2))
return
end
tp.tpr_teleport_player()
minetest.chat_send_player(name2, S("Request Accepted!"))
minetest.chat_send_player(name, chatmsg)
tpr_teleport_player()
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(name2), S("Request Accepted!"), 0xFFFFFF)
chat2.send_message(minetest.get_player_by_name(name), chatmsg, 0xFFFFFF)
end
end
-- Teleport Jump - Relative Position Teleportation by number of nodes
function tpj(player, param)
function tp.tpj(player, param)
local pname = minetest.get_player_by_name(player)
if param == "" then
minetest.chat_send_player(player, S("Usage: <x|y|z> <Number>"))
minetest.chat_send_player(player, S("Usage: <x|y|z> <number>"))
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(player), S("Usage: <x|y|z> <number>"), 0xFFFFFF)
end
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, S("Usage: <x|y|z> <Number>"))
minetest.chat_send_player(player, S("Usage: <x|y|z> <number>"))
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(player), S("Usage: <x|y|z> <number>"), 0xFFFFFF)
end
return false
end
@ -350,18 +455,27 @@ function tpj(player, param)
elseif args[1] == "z" then
target_coords["z"] = target_coords["z"] + tonumber(args[2])
else
minetest.chat_send_player(player, S("Not a valid axis. Valid options are X, Y or Z."))
minetest.chat_send_player(player, S("Not a valid axis. Valid options are X, Y or Z"))
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(player), S("Not a valid axis. Valid options are X, Y or Z"), 0xFFFFFF)
end
return
end
if can_teleport(target_coords) == false then
if tp.can_teleport(target_coords) == false then
minetest.chat_send_player(player, S("You cannot teleport to a location outside the map!"))
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(player), S("You cannot teleport to a location outside the map!"), 0xFFFFFF)
end
return
end
tpc_teleport_player(player)
tp.tpc_teleport_player(player)
end
-- Evade
function tpe(player)
function tp.tpe(player)
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(player), S("EVADE!"), 0xFFFFFF)
end
minetest.chat_send_player(player, S("EVADE!"))
local mindistance = 15
local maxdistance = 50
@ -380,7 +494,7 @@ function tpe(player)
distance = isnegative .. math.random(mindistance,maxdistance) -- the distance to jump
axis = options[math.random(3)]
local command = axis .. " " .. distance
tpj(player, command)
tp.tpj(player, command)
end
)
iteration = iteration + 0.5
@ -388,35 +502,49 @@ function tpe(player)
end
-- Register chatcommands
if enable_tpp_command then
if tp.enable_tpp_command then
minetest.register_chatcommand("tpp", {
description = S("Teleport to a place (i.e., spawn, shop)."),
params = S("<place> | leave empty to see available places"),
privs = {},
func = function(player, param)
local pname = minetest.get_player_by_name(player)
param = param:lower()
-- Show the available places to the player (taken from shivajiva101's POI mod, thanks!).
if param == "" then
local places = {}
if not available_places then available_places = {} end
for key, value in pairs(available_places) do
if not tp.available_places then tp.available_places = {} end
for key, value in pairs(tp.available_places) do
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(player), key, 0xFFFFFF)
end
table.insert(places, key)
end
if #places == 0 then
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(player), S("There are no places yet."), 0xFFFFFF)
end
return true, S("There are no places yet.")
end
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(player), S("Usage: /tpp <place>"), 0xFFFFFF)
end
table.insert(places, S("Usage: /tpp <place>"))
return true, table.concat(places, "\n")
-- Teleport player to the specified place (taken from shivajiva101's POI mod, thanks!).
elseif available_places[param] then
pos = {x = available_places[param].x, y = available_places[param].y, z = available_places[param].z}
tpp_teleport_player(player)
elseif tp.available_places[param] then
pos = {x = tp.available_places[param].x, y = tp.available_places[param].y, z = tp.available_places[param].z}
tp.tpp_teleport_player(player)
minetest.chat_send_player(player, S("Teleporting to @1.", param))
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(player), S("Teleporting to @1.", param), 0xFFFFFF)
end
-- Check if the place exists.
elseif not available_places[param] then
elseif not tp.available_places[param] then
minetest.chat_send_player(player, S("There is no place by that name. Keep in mind this is case-sensitive."))
if minetest.get_modpath("chat2") then
chat2.send_message(minetest.get_player_by_name(player), S("There is no place by that name. Keep in mind this is case-sensitive."), 0xFFFFFF)
end
return
end
end,
@ -427,49 +555,49 @@ minetest.register_chatcommand("tpr", {
description = S("Request teleport to another player"),
params = S("<playername> | leave playername empty to see help message"),
privs = {interact = true, tp = true},
func = tpr_send
func = tp.tpr_send
})
minetest.register_chatcommand("tphr", {
description = S("Request player to teleport to you"),
params = S("<playername> | leave playername empty to see help message"),
privs = {interact = true, tp = true},
func = tphr_send
func = tp.tphr_send
})
minetest.register_chatcommand("tpc", {
description = S("Teleport to coordinates"),
params = S("<coordinates> | leave coordinates empty to see help message"),
privs = {interact = true, tp_tpc = true, tp = true},
func = tpc_send
func = tp.tpc_send
})
minetest.register_chatcommand("tpj", {
description = S("Teleport to relative position"),
params = S("<axis> <distance> | leave empty to see help message"),
privs = {interact = true, tp_tpc = true, tp = true},
func = tpj
func = tp.tpj
})
minetest.register_chatcommand("tpe", {
description = S("Evade Enemy"),
privs = {interact = true, tp_tpc = true, tp = true},
func = tpe
func = tp.tpe
})
minetest.register_chatcommand("tpy", {
description = S("Accept teleport requests from another player"),
privs = {interact = true, tp = true},
func = tpr_accept
func = tp.tpr_accept
})
minetest.register_chatcommand("tpn", {
description = S("Deny teleport requests from another player"),
privs = {interact = true, tp = true},
func = tpr_deny
func = tp.tpr_deny
})
-- Log
if minetest.settings:get_bool("log_mods") then
minetest.log("action", S("[Teleport Request] TPS Teleport v@1 Loaded!", version))
minetest.log("action", S("[Teleport Request] TPS Teleport v@1 Loaded!", tp.version))
end

@ -16,35 +16,39 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: init.lua:19
#: config.lua
msgid "Let players teleport to other players (request will be sent)"
msgstr "Permite que los jugadores se teletransporten a otros jugadores (se enviará una solicitud)"
#: init.lua:43
#: config.lua
msgid "Gives full admin-access to a player."
msgstr "Da acceso total de administrador a un jugador."
#: init.lua:50
#: config.lua
msgid "Allow player to teleport to coordinates (if allowed by area protection)"
msgstr "Permite a los jugadores teletransportarse a las coordenadas especificadas (si esta permitido por la protección de la área)"
#: init.lua:105
msgid "You are teleporting to @1."
msgstr "Te estas teletransportando a @1."
#: init.lua
msgid "You are not allowed to send requests because you're muted."
msgstr "No tienes permiso para mandar solicitudes de teletransporte porque estás silenciado."
#: init.lua:111
#: init.lua
msgid "Usage: /tpr <Player name>"
msgstr "Uso: /tpr <jugador>"
#: init.lua:116
#: init.lua
msgid "There is no player by that name. Keep in mind this is case-sensitive, and the player must be online"
msgstr "No hay jugador con ese nombre. Tenga en cuenta que esto es caso-sensitivo, y el jugador debe de estar én linea."
#: init.lua:120
#: init.lua
msgid "You are teleporting to @1."
msgstr "Te estas teletransportando a @1."
#: init.lua
msgid "@1 is requesting to teleport to you. /tpy to accept"
msgstr "@1 esta pidiendo teletransportarse a ti. /tpy para aceptar"
#: init.lua:121
#: init.lua
msgid "Teleport request sent! It will timeout in @1 seconds"
msgstr "¡Solicitud enviada! Se agotara en @1 segundos"
@ -52,39 +56,39 @@ msgstr "¡Solicitud enviada! Se agotara en @1 segundos"
msgid "Request timed-out."
msgstr "La solicitud enviada expiró."
#: init.lua:147
#: init.lua
msgid "@1 is teleporting to you."
msgstr "@1 se esta teletransportando a ti."
#: init.lua:152
#: init.lua
msgid "Usage: /tphr <Player name>"
msgstr "Uso: /tphr <jugador>"
#: init.lua:160
#: init.lua
msgid "@1 is requesting that you teleport to them. /tpy to accept; /tpn to deny"
msgstr "@1 esta pidiendo que tu te teletransportes a el/ella. /tpy para aceptar, /tpn para denegar"
#: init.lua:187
#: init.lua
msgid "Usage: /tpc <x, y, z>"
msgstr "Uso: /tpc <x, y, z>"
#: init.lua:194
#: init.lua
msgid "You cannot teleport to a location outside the map!"
msgstr "¡No puedes teletransportarte afuera del mundo!"
#: init.lua:204
#: init.lua
msgid "Teleporting to: @1, @2, @3"
msgstr "Teletransportandose a: @1, @2, @3"
#: init.lua:215
#: init.lua
msgid "Error: @1 is protected by @2."
msgstr "Error: @1 esta protegido por @2."
#: init.lua:240
#: init.lua
msgid "Error: You do not have permission to teleport to those coordinates."
msgstr "Error: No tienes permiso para teletransportarte a esas coordenadas."
#: init.lua:258
#: init.lua
msgid "Teleport request denied."
msgstr "Solicitud denegada."
@ -96,63 +100,63 @@ msgstr "Tú denegaste la solicitud de teletransporte que @1 te mando."
msgid "Usage: /tpn allows you to deny teleport requests sent to you by other players."
msgstr "Uso: /tpn te permite denegar solicitudes enviadas para ti de otros jugadores."
#: init.lua:278
#: init.lua
msgid "Usage: /tpy allows you to accept teleport requests sent to you by other players"
msgstr "Uso: /tpy te permite aceptar solicitudes enviadas para ti de otros jugadores"
#: init.lua
msgid "@1 just disconnected/left (by timeout)."
msgstr "@1 se desconecto/fue."
msgid "@1 doesn't exist, or just disconnected/left (by timeout)."
msgstr "@1 no existe, o se desconecto/fue."
#: init.lua:317
#: init.lua
msgid "Request Accepted!"
msgstr "¡Solicitud aceptada!"
#: init.lua:330
#: init.lua
msgid "Usage: <x|y|z> <number>"
msgstr "Uso: <x|y|z> <numero>"
#: init.lua:353
msgid "Not a valid axis. Valid options are X, Y or Z"
msgstr "Eje invalido. Opciones validas son x, y, o z"
#: init.lua
msgid "Not a number!"
msgstr "¡No un número!"
#: init.lua:367
#: init.lua
msgid "Not a valid axis. Valid options are X, Y or Z"
msgstr "Eje invalido. Opciones validas son x, y, o z"
#: init.lua
msgid "EVADE!"
msgstr "¡EVADIR!"
#: init.lua:394
#: init.lua
msgid "Request teleport to another player."
msgstr "Enviar solicitud para teletransportarte a otro jugador."
#: init.lua:395
#: init.lua
msgid "<playername> | leave playername empty to see help message"
msgstr "<jugador> | Deje el nombre del jugador vacío para ver el mensaje de ayuda"
#: init.lua:401
#: init.lua
msgid "Request player to teleport to you"
msgstr "Solicita al jugador que se teletransporte a ti."
#: init.lua:408
#: init.lua
msgid "Teleport to coordinates"
msgstr "Teletransportarse a las coordenadas especificadas."
#: init.lua:409
#: init.lua
msgid "<coordinates> | leave coordinates empty to see help message"
msgstr "<coordenadas> | Deje las coordenadas vacías para ver el mensaje de ayuda"
#: init.lua:415
#: init.lua
msgid "Teleport to relative position"
msgstr "Teletransportarse a la posición relativa."
#: init.lua:416
#: init.lua
msgid "<axis> <distance> | leave empty to see help message"
msgstr "<eje> <distancia> | Deje vacío para ver el mensaje de ayuda"
#: init.lua:422
#: init.lua
msgid "Evade Enemy"
msgstr "Evadir enemigo."
@ -180,14 +184,14 @@ msgstr "Teletransportandose a @1."
msgid "There is no place by that name. Keep in mind this is case-sensitive."
msgstr "No hay lugar con ese nombre. Tenga en cuenta que esto es caso-sensitivo."
#: init.lua:428
#: init.lua
msgid "Accept teleport requests from another player"
msgstr "Aceptar solicitudes de otro jugador."
#: init.lua:434
#: init.lua
msgid "Deny teleport requests from another player"
msgstr "Denegar solicitudos de otro jugador."
#: init.lua:441
#: init.lua
msgid "[Teleport Request] TPS Teleport v@1 Loaded!"
msgstr "[TPS] Solicitud de teletransporte v@1 Cargado!"

@ -16,35 +16,39 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: init.lua:19
#: config.lua
msgid "Let players teleport to other players (request will be sent)"
msgstr ""
#: init.lua:43
#: config.lua
msgid "Gives full admin-access to a player."
msgstr ""
#: init.lua:50
#: config.lua
msgid "Allow player to teleport to coordinates (if allowed by area protection)"
msgstr ""
#: init.lua:105
msgid "You are teleporting to @1."
#: init.lua
msgid "You are not allowed to send requests because you're muted."
msgstr ""
#: init.lua:111
#: init.lua
msgid "Usage: /tpr <Player name>"
msgstr ""
#: init.lua:116
#: init.lua
msgid "There is no player by that name. Keep in mind this is case sensitive, and the player must be online"
msgstr ""
#: init.lua:120
#: init.lua
msgid "You are teleporting to @1."
msgstr ""
#: init.lua
msgid "@1 is requesting to teleport to you. /tpy to accept"
msgstr ""
#: init.lua:121
#: init.lua
msgid "Teleport request sent! It will timeout in @1 seconds"
msgstr ""
@ -52,39 +56,39 @@ msgstr ""
msgid "Request timed-out."
msgstr ""
#: init.lua:147
#: init.lua
msgid "@1 is teleporting to you."
msgstr ""
#: init.lua:152
#: init.lua
msgid "Usage: /tphr <Player name>"
msgstr ""
#: init.lua:160
#: init.lua
msgid "@1 is requesting that you teleport to them. /tpy to accept; /tpn to deny"
msgstr ""
#: init.lua:187
#: init.lua
msgid "Usage: /tpc <x, y, z>"
msgstr ""
#: init.lua:194
#: init.lua
msgid "You cannot teleport to a location outside the map!"
msgstr ""
#: init.lua:204
#: init.lua
msgid "Teleporting to: @1, @2, @3"
msgstr ""
#: init.lua:215
#: init.lua
msgid "Error: @1 is protected by @2."
msgstr ""
#: init.lua:240
#: init.lua
msgid "Error: You do not have permission to teleport to those coordinates."
msgstr ""
#: init.lua:258
#: init.lua
msgid "Teleport request denied."
msgstr ""
@ -96,31 +100,31 @@ msgstr ""
msgid "Usage: /tpn allows you to deny teleport requests sent to you by other players."
msgstr ""
#: init.lua:278
#: init.lua
msgid "Usage: /tpy allows you to accept teleport requests sent to you by other players"
msgstr ""
#: init.lua
msgid "@1 just disconnected/left (by timeout)."
msgid "@1 doesn't exist, or just disconnected/left (by timeout)."
msgstr ""
#: init.lua:317
#: init.lua
msgid "Request Accepted!"
msgstr ""
#: init.lua:330
#: init.lua
msgid "Usage: <x|y|z> <number>"
msgstr ""
#: init.lua:353
msgid "Not a valid axis. Valid options are X, Y or Z"
msgstr ""
#: init.lua
msgid "Not a number!"
msgstr ""
#: init.lua:367
#: init.lua
msgid "Not a valid axis. Valid options are X, Y or Z"
msgstr ""
#: init.lua
msgid "EVADE!"
msgstr ""
@ -148,46 +152,46 @@ msgstr ""
msgid "There is no place by that name. Keep in mind this is case-sensitive."
msgstr ""
#: init.lua:394
#: init.lua
msgid "Request teleport to another player."
msgstr ""
#: init.lua:395
#: init.lua
msgid "<playername> | leave playername empty to see help message"
msgstr ""
#: init.lua:401
#: init.lua
msgid "Request player to teleport to you"
msgstr ""
#: init.lua:408
#: init.lua
msgid "Teleport to coordinates"
msgstr ""
#: init.lua:409
#: init.lua
msgid "<coordinates> | leave coordinates empty to see help message"
msgstr ""
#: init.lua:415
#: init.lua
msgid "Teleport to relative position"
msgstr ""
#: init.lua:416
#: init.lua
msgid "<axis> <distance> | leave empty to see help message"
msgstr ""
#: init.lua:422
#: init.lua
msgid "Evade Enemy"
msgstr ""
#: init.lua:428
#: init.lua
msgid "Accept teleport requests from another player"
msgstr ""
#: init.lua:434
#: init.lua
msgid "Deny teleport requests from another player"
msgstr ""
#: init.lua:441
#: init.lua
msgid "[Teleport Request] TPS Teleport v@1 Loaded!"
msgstr ""

@ -1,3 +1,3 @@
name = tpr
optional_depends = areas, intllib
optional_depends = areas, intllib, beerchat, chat2
description = Allows players to send a request to other players to teleport to them, and do much more.

8
settingtypes.txt Normal file

@ -0,0 +1,8 @@
# Timeout delay (default is 60)
tp.timeout_delay (Timeout delay after a request is sent) int 60
# Enables immediate teleport to players for those who have tp_admin privilege (enabled by default)
tp.enable_immediate_teleport (Immediate teleport for those with tp_admin privilege) bool true
# Enables Teleport To Place command (disabled by default)
tp.enable_tpp_command (Enable Teleport To Place command) bool false

@ -1,2 +0,0 @@
This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License.
To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.

@ -1,2 +0,0 @@
This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License.
To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.