mirror of
https://github.com/minetest-mods/teleport-request.git
synced 2025-01-08 14:07:28 +01:00
Big improvement
Almost done, looking into some issues that needs fixing.
This commit is contained in:
parent
5f424b9b1f
commit
c6b8df9d6f
70
init.lua
70
init.lua
@ -287,83 +287,37 @@ end
|
|||||||
function tpr_accept(name, param)
|
function tpr_accept(name, param)
|
||||||
-- Check to prevent constant teleporting.
|
-- Check to prevent constant teleporting.
|
||||||
if not tpr_list[name]
|
if not tpr_list[name]
|
||||||
and not tphr_list[name] then
|
and not tphr_list[name]
|
||||||
minetest.chat_send_player(name, S("Usage: /tpy allows you to accept teleport requests sent to you by other players"))
|
or param == "" then
|
||||||
|
minetest.chat_send_player(name, S("Usage: /tpy <player>"))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if tpr_list[name] then
|
if tpr_list[name] then
|
||||||
name2 = tpr_list[name]
|
name2 = tpr_list[name]
|
||||||
source = minetest.get_player_by_name(name)
|
source = minetest.get_player_by_name(name)
|
||||||
target = minetest.get_player_by_name(name2)
|
target = minetest.get_player_by_name(param)
|
||||||
chatmsg = S("@1 is teleporting to you.", name2)
|
chatmsg = S("@1 is teleporting to you.", param)
|
||||||
tpr_list[name] = nil
|
tpr_list[name] = nil
|
||||||
elseif tphr_list[name] then
|
elseif tphr_list[name] then
|
||||||
name2 = tphr_list[name]
|
name2 = tphr_list[name]
|
||||||
source = minetest.get_player_by_name(name2)
|
source = minetest.get_player_by_name(param)
|
||||||
target = minetest.get_player_by_name(name)
|
target = minetest.get_player_by_name(name)
|
||||||
chatmsg = S("You are teleporting to @1.", name2)
|
chatmsg = S("You are teleporting to @1.", param)
|
||||||
tphr_list[name] = nil
|
tphr_list[name] = nil
|
||||||
-- Let the player choose which player to teleport to when there are multiple requests.
|
|
||||||
-- THIS IS AN UNTESTED FUNCTION. CHECK IT AT YOUR OWN RISK.
|
|
||||||
elseif tpr_list[name] > 1 then
|
|
||||||
name2 = tpr_list[name]
|
|
||||||
chatmsg = S("@1 is teleporting to you.", name2)
|
|
||||||
param = param:lower()
|
|
||||||
minetest.chat_send_player(name, S("Use /tpy <player> and choose a player to teleport to:"))
|
|
||||||
local tp = {}
|
|
||||||
for key, value in pairs(tpr_list) do
|
|
||||||
table.insert(tp, key)
|
|
||||||
end
|
|
||||||
if param == "" then
|
|
||||||
minetest.chat_send_player(name, S("Use /tpy <player> and choose a player to teleport to:"))
|
|
||||||
for key, value in pairs(tpr_list) do
|
|
||||||
table.insert(tp, key)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
-- Teleport player to the specified player
|
|
||||||
if tpr_list[param] then
|
|
||||||
tpr_teleport_player(param)
|
|
||||||
minetest.chat_send_player(param, S("Request Accepted!"))
|
|
||||||
minetest.chat_send_player(name, chatmsg)
|
|
||||||
--tpr_list[name] = nil
|
|
||||||
end
|
|
||||||
elseif tphr_list[name] > 1 then
|
|
||||||
name2 = tphr_list[name]
|
|
||||||
chatmsg = S("You are teleporting to @1.", name2)
|
|
||||||
param = param:lower()
|
|
||||||
minetest.chat_send_player(name, S("Use /tpy <player> and choose a player to teleport to:"))
|
|
||||||
local tp = {}
|
|
||||||
for key, value in pairs(tphr_list) do
|
|
||||||
table.insert(tp, key)
|
|
||||||
end
|
|
||||||
if param == "" then
|
|
||||||
minetest.chat_send_player(name, S("Use /tpy <player> and choose a player to teleport to:"))
|
|
||||||
for key, value in pairs(tphr_list) do
|
|
||||||
table.insert(tp, key)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
-- Teleport player to the specified player
|
|
||||||
if tphr_list[param] then
|
|
||||||
tpr_teleport_player(param)
|
|
||||||
minetest.chat_send_player(param, S("Request Accepted!"))
|
|
||||||
minetest.chat_send_player(name, chatmsg)
|
|
||||||
--tpr_list[name] = nil
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 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 just disconnected/left (by timeout).", name2))
|
minetest.chat_send_player(name, S("@1 doesn't exist, or just disconnected/left (by timeout).", param))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.chat_send_player(name2, S("Request Accepted!"))
|
|
||||||
minetest.chat_send_player(name, chatmsg)
|
|
||||||
tpr_teleport_player()
|
tpr_teleport_player()
|
||||||
|
minetest.chat_send_player(param, S("Request Accepted!"))
|
||||||
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user