mirror of
https://github.com/minetest-mods/teleport-request.git
synced 2024-10-05 17:23:16 +02:00
parent
cf6a550378
commit
ee4954bdad
@ -70,10 +70,8 @@ minetest.register_chatcommand("tpf", {
|
|||||||
description = S("Show all teleport requests, made by you or to you, that are still active"),
|
description = S("Show all teleport requests, made by you or to you, that are still active"),
|
||||||
privs = {interact = true, tp = true},
|
privs = {interact = true, tp = true},
|
||||||
func = function(player)
|
func = function(player)
|
||||||
local playername = minetest.get_player_by_name(player)
|
tp.tpf_update_time[player] = true
|
||||||
|
tp.list_requests(player)
|
||||||
tp.tpf_update_time[playername] = true
|
|
||||||
tp.list_requests(playername)
|
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -200,9 +200,7 @@ function tp.deny_request(id, own)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function tp.list_requests(player)
|
function tp.list_requests(playername)
|
||||||
local playername = player:get_player_name()
|
|
||||||
|
|
||||||
local sent_requests = tp.get_requests(playername, "sender")
|
local sent_requests = tp.get_requests(playername, "sender")
|
||||||
local received_requests = tp.get_requests(playername, "receiver")
|
local received_requests = tp.get_requests(playername, "receiver")
|
||||||
local area_requests = tp.get_requests(playername, "area")
|
local area_requests = tp.get_requests(playername, "area")
|
||||||
@ -284,14 +282,14 @@ function tp.list_requests(player)
|
|||||||
|
|
||||||
local function update_time()
|
local function update_time()
|
||||||
if formspec == "" or string.find(formspec, S("You have no requests.")) then
|
if formspec == "" or string.find(formspec, S("You have no requests.")) then
|
||||||
tp.tpf_update_time[player] = false
|
tp.tpf_update_time[playername] = false
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if tp.tpf_update_time[player] then
|
if tp.tpf_update_time[playername] then
|
||||||
-- TODO: find a way to edit the text only and update
|
-- TODO: find a way to edit the text only and update
|
||||||
-- the formspec without re-calling the function.
|
-- the formspec without re-calling the function.
|
||||||
tp.list_requests(player)
|
tp.list_requests(playername)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -327,14 +325,13 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if changes and not fields.quit then
|
if changes and not fields.quit then
|
||||||
tp.tpf_update_time[player] = true
|
tp.tpf_update_time[playername] = true
|
||||||
tp.list_requests(player)
|
tp.list_requests(playername)
|
||||||
elseif fields.quit then
|
elseif fields.quit then
|
||||||
tp.tpf_update_time[player] = false
|
tp.tpf_update_time[playername] = false
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
function tp.get_requests(playername, party)
|
function tp.get_requests(playername, party)
|
||||||
local list
|
local list
|
||||||
if party == "sender" then
|
if party == "sender" then
|
||||||
@ -519,9 +516,7 @@ function tp.tpr_send(sender, receiver)
|
|||||||
band = true
|
band = true
|
||||||
end
|
end
|
||||||
end, sender, receiver)
|
end, sender, receiver)
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
-- Compatibility with beerchat
|
-- Compatibility with beerchat
|
||||||
if minetest.get_modpath("beerchat") and not minetest.check_player_privs(sender, {tp_admin = true}) then
|
if minetest.get_modpath("beerchat") and not minetest.check_player_privs(sender, {tp_admin = true}) then
|
||||||
if receiver == "" then
|
if receiver == "" then
|
||||||
@ -622,9 +617,7 @@ function tp.tphr_send(sender, receiver)
|
|||||||
band = true
|
band = true
|
||||||
end
|
end
|
||||||
end, sender, receiver)
|
end, sender, receiver)
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
-- Compatibility with beerchat
|
-- Compatibility with beerchat
|
||||||
if minetest.get_modpath("beerchat") and not minetest.check_player_privs(sender, {tp_admin = true}) then
|
if minetest.get_modpath("beerchat") and not minetest.check_player_privs(sender, {tp_admin = true}) then
|
||||||
if receiver == "" then
|
if receiver == "" then
|
||||||
@ -787,6 +780,7 @@ function tp.tpr_deny(name)
|
|||||||
if (tp.count_requests(name, "sender") + tp.count_requests(name, "receiver")) > 1 then
|
if (tp.count_requests(name, "sender") + tp.count_requests(name, "receiver")) > 1 then
|
||||||
-- Show formspec for decision
|
-- Show formspec for decision
|
||||||
tp.list_requests(name)
|
tp.list_requests(name)
|
||||||
|
tp.tpf_update_time[name] = true
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -814,6 +808,7 @@ function tp.tpr_accept(name)
|
|||||||
if tp.count_requests(name, "receiver") > 1 then
|
if tp.count_requests(name, "receiver") > 1 then
|
||||||
-- Show formspec for decision
|
-- Show formspec for decision
|
||||||
tp.list_requests(name)
|
tp.list_requests(name)
|
||||||
|
tp.tpf_update_time[name] = true
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user