mirror of
https://github.com/minetest-mods/teleport-request.git
synced 2025-01-08 22:17:27 +01:00
Support for beerchat (UNTESTED)
Thanks to @6r1d for the idea! This commit also improves the mod and makes the mod better.
This commit is contained in:
parent
59d59f83b2
commit
d6cf756769
194
init.lua
194
init.lua
@ -28,6 +28,8 @@ Optional dependencies: areas, intllib
|
|||||||
New release by RobbieF under new mod: tps_teleport - http://blog.minetest.tv/teleport-request/
|
New release by RobbieF under new mod: tps_teleport - http://blog.minetest.tv/teleport-request/
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
|
tp = {}
|
||||||
|
|
||||||
-- Load support for intllib.
|
-- Load support for intllib.
|
||||||
local MP = minetest.get_modpath(minetest.get_current_modname())
|
local MP = minetest.get_modpath(minetest.get_current_modname())
|
||||||
local S, NS = dofile(MP.."/intllib.lua")
|
local S, NS = dofile(MP.."/intllib.lua")
|
||||||
@ -35,43 +37,43 @@ local S, NS = dofile(MP.."/intllib.lua")
|
|||||||
-- Load configuration.
|
-- Load configuration.
|
||||||
dofile(MP.."/config.lua")
|
dofile(MP.."/config.lua")
|
||||||
|
|
||||||
local tpr_list = {}
|
tp.tpr_list = {}
|
||||||
local tphr_list = {}
|
tp.tphr_list = {}
|
||||||
|
|
||||||
local map_size = 30912
|
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
|
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
|
end
|
||||||
|
|
||||||
-- Teleport player to a player (used in "/tpr" and in "/tphr" command).
|
-- 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_coords = source:get_pos()
|
||||||
local target_sound = target: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_coords, gain = 0.5, max_hear_distance = 10})
|
||||||
minetest.sound_play("whoosh", {pos = target_sound, 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
|
end
|
||||||
|
|
||||||
-- TPC & TPJ
|
-- TPC & TPJ
|
||||||
function tpc_teleport_player(player)
|
function tp.tpc_teleport_player(player)
|
||||||
local pname = minetest.get_player_by_name(player)
|
local pname = minetest.get_player_by_name(player)
|
||||||
minetest.sound_play("whoosh", {pos = pname:get_pos(), gain = 0.5, max_hear_distance = 10})
|
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})
|
minetest.sound_play("whoosh", {pos = target_coords, gain = 0.5, max_hear_distance = 10})
|
||||||
--parti2(target_coords)
|
--tp.parti2(target_coords)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- TPP
|
-- TPP
|
||||||
function tpp_teleport_player(player)
|
function tp.tpp_teleport_player(player)
|
||||||
local pname = minetest.get_player_by_name(player)
|
local pname = minetest.get_player_by_name(player)
|
||||||
minetest.sound_play("whoosh", {pos = pname:get_pos(), gain = 0.5, max_hear_distance = 10})
|
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})
|
minetest.sound_play("whoosh", {pos = pos, gain = 0.5, max_hear_distance = 10})
|
||||||
--parti2(target_coords)
|
--tp.parti2(target_coords)
|
||||||
end
|
end
|
||||||
|
|
||||||
function find_free_position_near(pos)
|
function tp.find_free_position_near(pos)
|
||||||
local tries = {
|
local tries = {
|
||||||
{x=1,y=0,z=0},
|
{x=1,y=0,z=0},
|
||||||
{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
|
return pos, false
|
||||||
end
|
end
|
||||||
|
|
||||||
function parti(pos)
|
function tp.parti(pos)
|
||||||
minetest.add_particlespawner(50, 0.4,
|
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=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},
|
{x=0, y=5, z=0}, {x=0, y=0, z=0},
|
||||||
@ -98,7 +100,7 @@ function parti(pos)
|
|||||||
"tps_portal_parti.png")
|
"tps_portal_parti.png")
|
||||||
end
|
end
|
||||||
|
|
||||||
function parti2(pos)
|
function tp.parti2(pos)
|
||||||
minetest.add_particlespawner(50, 0.4,
|
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=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},
|
{x=0, y=-5, z=0}, {x=0, y=0, z=0},
|
||||||
@ -110,35 +112,42 @@ function parti2(pos)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Teleport Request System
|
-- Teleport Request System
|
||||||
function clear_tpr_list(name)
|
function tp.clear_tpr_list(name)
|
||||||
if tpr_list[name] then
|
if tp.tpr_list[name] then
|
||||||
tpr_list[name] = nil
|
tp.tpr_list[name] = nil
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function clear_tphr_list(name)
|
function tp.clear_tphr_list(name)
|
||||||
if tphr_list[name] then
|
if tp.tphr_list[name] then
|
||||||
tphr_list[name] = nil
|
tp.tphr_list[name] = nil
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Clear requests when the player leaves
|
-- Clear requests when the player leaves
|
||||||
minetest.register_on_leaveplayer(function(name)
|
minetest.register_on_leaveplayer(function(name)
|
||||||
if tpr_list[name] then
|
if tp.tpr_list[name] then
|
||||||
tpr_list[name] = nil
|
tp.tpr_list[name] = nil
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if tphr_list[name] then
|
if tp.tphr_list[name] then
|
||||||
tphr_list[name] = nil
|
tp.tphr_list[name] = nil
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
function tpr_send(sender, receiver)
|
function tp.tpr_send(sender, receiver)
|
||||||
if minetest.check_player_privs(sender, {tp_admin = true}) and enable_immediate_teleport then
|
-- 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."))
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if minetest.check_player_privs(sender, {tp_admin = true}) and tp.enable_immediate_teleport then
|
||||||
if receiver == "" then
|
if receiver == "" then
|
||||||
minetest.chat_send_player(sender, S("Usage: /tpr <Player name>"))
|
minetest.chat_send_player(sender, S("Usage: /tpr <Player name>"))
|
||||||
return
|
return
|
||||||
@ -147,8 +156,8 @@ function tpr_send(sender, receiver)
|
|||||||
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"))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
tpr_list[receiver] = sender
|
tp.tpr_list[receiver] = sender
|
||||||
tpr_accept(receiver)
|
tp.tpr_accept(receiver)
|
||||||
minetest.chat_send_player(sender, S("You are teleporting to @1.", receiver))
|
minetest.chat_send_player(sender, S("You are teleporting to @1.", receiver))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -166,11 +175,11 @@ function tpr_send(sender, receiver)
|
|||||||
minetest.chat_send_player(receiver, S("@1 is requesting to teleport to you. /tpy to accept", sender))
|
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))
|
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.
|
-- Write name values to list and clear old values.
|
||||||
tpr_list[receiver] = sender
|
tp.tpr_list[receiver] = sender
|
||||||
-- Teleport timeout delay
|
-- Teleport timeout delay
|
||||||
minetest.after(timeout_delay, function(name)
|
minetest.after(tp.timeout_delay, function(name)
|
||||||
if tpr_list[name] then
|
if tp.tpr_list[name] then
|
||||||
tpr_list[name] = nil
|
tp.tpr_list[name] = nil
|
||||||
minetest.chat_send_player(sender, S("Request timed-out."))
|
minetest.chat_send_player(sender, S("Request timed-out."))
|
||||||
minetest.chat_send_player(receiver, S("Request timed-out."))
|
minetest.chat_send_player(receiver, S("Request timed-out."))
|
||||||
return
|
return
|
||||||
@ -178,8 +187,15 @@ function tpr_send(sender, receiver)
|
|||||||
end, receiver)
|
end, receiver)
|
||||||
end
|
end
|
||||||
|
|
||||||
function tphr_send(sender, receiver)
|
function tp.tphr_send(sender, receiver)
|
||||||
if minetest.check_player_privs(sender, {tp_admin = true}) and enable_immediate_teleport then
|
-- 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."))
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if minetest.check_player_privs(sender, {tp_admin = true}) and tp.enable_immediate_teleport then
|
||||||
if receiver == "" then
|
if receiver == "" then
|
||||||
minetest.chat_send_player(sender, S("Usage: /tphr <Player name>"))
|
minetest.chat_send_player(sender, S("Usage: /tphr <Player name>"))
|
||||||
return
|
return
|
||||||
@ -188,8 +204,8 @@ function tphr_send(sender, receiver)
|
|||||||
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"))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
tphr_list[receiver] = sender
|
tp.tphr_list[receiver] = sender
|
||||||
tpr_accept(receiver)
|
tp.tpr_accept(receiver)
|
||||||
minetest.chat_send_player(sender, S("@1 is teleporting to you.", receiver))
|
minetest.chat_send_player(sender, S("@1 is teleporting to you.", receiver))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -206,11 +222,11 @@ function tphr_send(sender, receiver)
|
|||||||
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(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))
|
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.
|
-- Write name values to list and clear old values.
|
||||||
tphr_list[receiver] = sender
|
tp.tphr_list[receiver] = sender
|
||||||
-- Teleport timeout delay
|
-- Teleport timeout delay
|
||||||
minetest.after(timeout_delay, function(name)
|
minetest.after(tp.timeout_delay, function(name)
|
||||||
if tphr_list[name] then
|
if tp.tphr_list[name] then
|
||||||
tphr_list[name] = nil
|
tp.tphr_list[name] = nil
|
||||||
minetest.chat_send_player(sender, S("Request timed-out."))
|
minetest.chat_send_player(sender, S("Request timed-out."))
|
||||||
minetest.chat_send_player(receiver, S("Request timed-out."))
|
minetest.chat_send_player(receiver, S("Request timed-out."))
|
||||||
return
|
return
|
||||||
@ -218,7 +234,7 @@ function tphr_send(sender, receiver)
|
|||||||
end, receiver)
|
end, receiver)
|
||||||
end
|
end
|
||||||
|
|
||||||
function tpc_send(player, coordinates)
|
function tp.tpc_send(player, coordinates)
|
||||||
|
|
||||||
local posx,posy,posz = string.match(coordinates, "^(-?%d+), (-?%d+), (-?%d+)$")
|
local posx,posy,posz = string.match(coordinates, "^(-?%d+), (-?%d+), (-?%d+)$")
|
||||||
local pname = minetest.get_player_by_name(player)
|
local pname = minetest.get_player_by_name(player)
|
||||||
@ -236,7 +252,7 @@ function tpc_send(player, coordinates)
|
|||||||
|
|
||||||
target_coords = {x=posx, y=posy, z=posz}
|
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!"))
|
minetest.chat_send_player(player, S("You cannot teleport to a location outside the map!"))
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
@ -244,8 +260,8 @@ function tpc_send(player, coordinates)
|
|||||||
-- If the area is protected, reject the user's request to teleport to these coordinates
|
-- 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.
|
-- 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
|
-- Admin user (priv "tp_admin") overrides all protection
|
||||||
if minetest.check_player_privs(pname, {tp_admin=true}) then
|
if minetest.check_player_privs(pname, {tp_admin = true}) then
|
||||||
tpc_teleport_player(player)
|
tp.tpc_teleport_player(player)
|
||||||
minetest.chat_send_player(player, S("Teleporting to: @1, @2, @3", posx, posy, posz))
|
minetest.chat_send_player(player, S("Teleporting to: @1, @2, @3", posx, posy, posz))
|
||||||
else
|
else
|
||||||
if minetest.check_player_privs(pname, {tp_tpc = true}) then
|
if minetest.check_player_privs(pname, {tp_tpc = true}) then
|
||||||
@ -257,7 +273,7 @@ function tpc_send(player, coordinates)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
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))
|
minetest.chat_send_player(player, S("Teleporting to: @1, @2, @3", posx, posy, posz))
|
||||||
else
|
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 coordinates."))
|
||||||
@ -266,17 +282,17 @@ function tpc_send(player, coordinates)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function tpr_deny(name)
|
function tp.tpr_deny(name)
|
||||||
if tpr_list[name] then
|
if tp.tpr_list[name] then
|
||||||
name2 = tpr_list[name]
|
name2 = tp.tpr_list[name]
|
||||||
minetest.chat_send_player(name2, S("Teleport request denied."))
|
minetest.chat_send_player(name2, S("Teleport request denied."))
|
||||||
minetest.chat_send_player(name, S("You denied the request @1 sent you.", name2))
|
minetest.chat_send_player(name, S("You denied the request @1 sent you.", name2))
|
||||||
tpr_list[name] = nil
|
tp.tpr_list[name] = nil
|
||||||
elseif tphr_list[name] then
|
elseif tp.tphr_list[name] then
|
||||||
name2 = tphr_list[name]
|
name2 = tphr_list[name]
|
||||||
minetest.chat_send_player(name2, S("Teleport request denied."))
|
minetest.chat_send_player(name2, S("Teleport request denied."))
|
||||||
minetest.chat_send_player(name, S("You denied the request @1 sent you.", name2))
|
minetest.chat_send_player(name, S("You denied the request @1 sent you.", name2))
|
||||||
tphr_list[name] = nil
|
tp.tphr_list[name] = nil
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(name, S("Usage: /tpn allows you to deny teleport requests sent to you by other players."))
|
minetest.chat_send_player(name, S("Usage: /tpn allows you to deny teleport requests sent to you by other players."))
|
||||||
return
|
return
|
||||||
@ -284,27 +300,26 @@ function tpr_deny(name)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Teleport Accept Systems
|
-- Teleport Accept Systems
|
||||||
function tpr_accept(name, param)
|
function tp.tpr_accept(name, param)
|
||||||
-- Check to prevent constant teleporting.
|
-- Check to prevent constant teleporting.
|
||||||
if not tpr_list[name]
|
if not tp.tpr_list[name]
|
||||||
and not tphr_list[name]
|
and not tp.tphr_list[name]
|
||||||
or param == "" then
|
|
||||||
minetest.chat_send_player(name, S("Usage: /tpy <player>"))
|
minetest.chat_send_player(name, S("Usage: /tpy <player>"))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if tpr_list[name] then
|
if tp.tpr_list[name] then
|
||||||
name2 = tpr_list[name]
|
name2 = tp.tpr_list[name]
|
||||||
source = minetest.get_player_by_name(name)
|
source = minetest.get_player_by_name(name)
|
||||||
target = minetest.get_player_by_name(param)
|
target = minetest.get_player_by_name(name2)
|
||||||
chatmsg = S("@1 is teleporting to you.", param)
|
chatmsg = S("@1 is teleporting to you.", name2)
|
||||||
tpr_list[name] = nil
|
tp.tpr_list[name] = nil
|
||||||
elseif tphr_list[name] then
|
elseif tp.tphr_list[name] then
|
||||||
name2 = tphr_list[name]
|
name2 = tp.tphr_list[name]
|
||||||
source = minetest.get_player_by_name(param)
|
source = minetest.get_player_by_name(name2)
|
||||||
target = minetest.get_player_by_name(name)
|
target = minetest.get_player_by_name(name)
|
||||||
chatmsg = S("You are teleporting to @1.", param)
|
chatmsg = S("You are teleporting to @1.", name2)
|
||||||
tphr_list[name] = nil
|
tp.tphr_list[name] = nil
|
||||||
else
|
else
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -312,16 +327,16 @@ function tpr_accept(name, param)
|
|||||||
-- Could happen if either player disconnects (or timeout); if so just abort
|
-- Could happen if either player disconnects (or timeout); if so just abort
|
||||||
if not source
|
if not source
|
||||||
or not target then
|
or not target then
|
||||||
minetest.chat_send_player(name, S("@1 doesn't exist, or just disconnected/left (by timeout).", param))
|
minetest.chat_send_player(name, S("@1 doesn't exist, or just disconnected/left (by timeout).", name2))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
tpr_teleport_player()
|
tp.tpr_teleport_player()
|
||||||
minetest.chat_send_player(param, S("Request Accepted!"))
|
minetest.chat_send_player(name2, S("Request Accepted!"))
|
||||||
minetest.chat_send_player(name, chatmsg)
|
minetest.chat_send_player(name, chatmsg)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Teleport Jump - Relative Position Teleportation by number of nodes
|
-- 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)
|
local pname = minetest.get_player_by_name(player)
|
||||||
|
|
||||||
if param == "" then
|
if param == "" then
|
||||||
@ -351,15 +366,15 @@ function tpj(player, param)
|
|||||||
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."))
|
||||||
return
|
return
|
||||||
end
|
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!"))
|
minetest.chat_send_player(player, S("You cannot teleport to a location outside the map!"))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
tpc_teleport_player(player)
|
tp.tpc_teleport_player(player)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Evade
|
-- Evade
|
||||||
function tpe(player)
|
function tp.tpe(player)
|
||||||
minetest.chat_send_player(player, S("EVADE!"))
|
minetest.chat_send_player(player, S("EVADE!"))
|
||||||
local mindistance = 15
|
local mindistance = 15
|
||||||
local maxdistance = 50
|
local maxdistance = 50
|
||||||
@ -378,7 +393,7 @@ function tpe(player)
|
|||||||
distance = isnegative .. math.random(mindistance,maxdistance) -- the distance to jump
|
distance = isnegative .. math.random(mindistance,maxdistance) -- the distance to jump
|
||||||
axis = options[math.random(3)]
|
axis = options[math.random(3)]
|
||||||
local command = axis .. " " .. distance
|
local command = axis .. " " .. distance
|
||||||
tpj(player, command)
|
tp.tpj(player, command)
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
iteration = iteration + 0.5
|
iteration = iteration + 0.5
|
||||||
@ -386,20 +401,19 @@ function tpe(player)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Register chatcommands
|
-- Register chatcommands
|
||||||
if enable_tpp_command then
|
if tp.enable_tpp_command then
|
||||||
minetest.register_chatcommand("tpp", {
|
minetest.register_chatcommand("tpp", {
|
||||||
description = S("Teleport to a place (i.e., spawn, shop)."),
|
description = S("Teleport to a place (i.e., spawn, shop)."),
|
||||||
params = S("<place> | leave empty to see available places"),
|
params = S("<place> | leave empty to see available places"),
|
||||||
privs = {},
|
privs = {},
|
||||||
func = function(player, param)
|
func = function(player, param)
|
||||||
local pname = minetest.get_player_by_name(player)
|
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!).
|
-- Show the available places to the player (taken from shivajiva101's POI mod, thanks!).
|
||||||
if param == "" then
|
if param == "" then
|
||||||
local places = {}
|
local places = {}
|
||||||
if not available_places then available_places = {} end
|
if not tp.available_places then tp.available_places = {} end
|
||||||
for key, value in pairs(available_places) do
|
for key, value in pairs(tp.available_places) do
|
||||||
table.insert(places, key)
|
table.insert(places, key)
|
||||||
end
|
end
|
||||||
if #places == 0 then
|
if #places == 0 then
|
||||||
@ -408,12 +422,12 @@ if enable_tpp_command then
|
|||||||
table.insert(places, S("Usage: /tpp <place>"))
|
table.insert(places, S("Usage: /tpp <place>"))
|
||||||
return true, table.concat(places, "\n")
|
return true, table.concat(places, "\n")
|
||||||
-- Teleport player to the specified place (taken from shivajiva101's POI mod, thanks!).
|
-- Teleport player to the specified place (taken from shivajiva101's POI mod, thanks!).
|
||||||
elseif available_places[param] then
|
elseif tp.available_places[param] then
|
||||||
pos = {x = available_places[param].x, y = available_places[param].y, z = available_places[param].z}
|
pos = {x = tp.available_places[param].x, y = tp.available_places[param].y, z = tp.available_places[param].z}
|
||||||
tpp_teleport_player(player)
|
tp.tpp_teleport_player(player)
|
||||||
minetest.chat_send_player(player, S("Teleporting to @1.", param))
|
minetest.chat_send_player(player, S("Teleporting to @1.", param))
|
||||||
-- Check if the place exists.
|
-- 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."))
|
minetest.chat_send_player(player, S("There is no place by that name. Keep in mind this is case-sensitive."))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -425,49 +439,49 @@ minetest.register_chatcommand("tpr", {
|
|||||||
description = S("Request teleport to another player"),
|
description = S("Request teleport to another player"),
|
||||||
params = S("<playername> | leave playername empty to see help message"),
|
params = S("<playername> | leave playername empty to see help message"),
|
||||||
privs = {interact = true, tp = true},
|
privs = {interact = true, tp = true},
|
||||||
func = tpr_send
|
func = tp.tpr_send
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_chatcommand("tphr", {
|
minetest.register_chatcommand("tphr", {
|
||||||
description = S("Request player to teleport to you"),
|
description = S("Request player to teleport to you"),
|
||||||
params = S("<playername> | leave playername empty to see help message"),
|
params = S("<playername> | leave playername empty to see help message"),
|
||||||
privs = {interact = true, tp = true},
|
privs = {interact = true, tp = true},
|
||||||
func = tphr_send
|
func = tp.tphr_send
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_chatcommand("tpc", {
|
minetest.register_chatcommand("tpc", {
|
||||||
description = S("Teleport to coordinates"),
|
description = S("Teleport to coordinates"),
|
||||||
params = S("<coordinates> | leave coordinates empty to see help message"),
|
params = S("<coordinates> | leave coordinates empty to see help message"),
|
||||||
privs = {interact = true, tp_tpc = true, tp = true},
|
privs = {interact = true, tp_tpc = true, tp = true},
|
||||||
func = tpc_send
|
func = tp.tpc_send
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_chatcommand("tpj", {
|
minetest.register_chatcommand("tpj", {
|
||||||
description = S("Teleport to relative position"),
|
description = S("Teleport to relative position"),
|
||||||
params = S("<axis> <distance> | leave empty to see help message"),
|
params = S("<axis> <distance> | leave empty to see help message"),
|
||||||
privs = {interact = true, tp_tpc = true, tp = true},
|
privs = {interact = true, tp_tpc = true, tp = true},
|
||||||
func = tpj
|
func = tp.tpj
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_chatcommand("tpe", {
|
minetest.register_chatcommand("tpe", {
|
||||||
description = S("Evade Enemy"),
|
description = S("Evade Enemy"),
|
||||||
privs = {interact = true, tp_tpc = true, tp = true},
|
privs = {interact = true, tp_tpc = true, tp = true},
|
||||||
func = tpe
|
func = tp.tpe
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_chatcommand("tpy", {
|
minetest.register_chatcommand("tpy", {
|
||||||
description = S("Accept teleport requests from another player"),
|
description = S("Accept teleport requests from another player"),
|
||||||
privs = {interact = true, tp = true},
|
privs = {interact = true, tp = true},
|
||||||
func = tpr_accept
|
func = tp.tpr_accept
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_chatcommand("tpn", {
|
minetest.register_chatcommand("tpn", {
|
||||||
description = S("Deny teleport requests from another player"),
|
description = S("Deny teleport requests from another player"),
|
||||||
privs = {interact = true, tp = true},
|
privs = {interact = true, tp = true},
|
||||||
func = tpr_deny
|
func = tp.tpr_deny
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Log
|
-- Log
|
||||||
if minetest.settings:get_bool("log_mods") then
|
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
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user