Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TPF issues #58

Merged
merged 1 commit into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,8 @@ minetest.register_chatcommand("tpf", {
description = S("Show all teleport requests, made by you or to you, that are still active"),
privs = {interact = true, tp = true},
func = function(player)
local playername = minetest.get_player_by_name(player)

tp.tpf_update_time[playername] = true
tp.list_requests(playername)
tp.tpf_update_time[player] = true
tp.list_requests(player)
end
})

Expand Down
23 changes: 9 additions & 14 deletions functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,7 @@ function tp.deny_request(id, own)
end
end

function tp.list_requests(player)
local playername = player:get_player_name()

function tp.list_requests(playername)
local sent_requests = tp.get_requests(playername, "sender")
local received_requests = tp.get_requests(playername, "receiver")
local area_requests = tp.get_requests(playername, "area")
Expand Down Expand Up @@ -284,14 +282,14 @@ function tp.list_requests(player)

local function update_time()
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
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
-- the formspec without re-calling the function.
tp.list_requests(player)
tp.list_requests(playername)
end
end

Expand Down Expand Up @@ -327,14 +325,13 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end

if changes and not fields.quit then
tp.tpf_update_time[player] = true
tp.list_requests(player)
tp.tpf_update_time[playername] = true
tp.list_requests(playername)
elseif fields.quit then
tp.tpf_update_time[player] = false
tp.tpf_update_time[playername] = false
end
end)


function tp.get_requests(playername, party)
local list
if party == "sender" then
Expand Down Expand Up @@ -519,9 +516,7 @@ function tp.tpr_send(sender, receiver)
band = true
end
end, sender, receiver)

else

-- Compatibility with beerchat
if minetest.get_modpath("beerchat") and not minetest.check_player_privs(sender, {tp_admin = true}) then
if receiver == "" then
Expand Down Expand Up @@ -622,9 +617,7 @@ function tp.tphr_send(sender, receiver)
band = true
end
end, sender, receiver)

else

-- Compatibility with beerchat
if minetest.get_modpath("beerchat") and not minetest.check_player_privs(sender, {tp_admin = true}) then
if receiver == "" then
Expand Down Expand Up @@ -787,6 +780,7 @@ function tp.tpr_deny(name)
if (tp.count_requests(name, "sender") + tp.count_requests(name, "receiver")) > 1 then
-- Show formspec for decision
tp.list_requests(name)
tp.tpf_update_time[name] = true
return
end

Expand Down Expand Up @@ -814,6 +808,7 @@ function tp.tpr_accept(name)
if tp.count_requests(name, "receiver") > 1 then
-- Show formspec for decision
tp.list_requests(name)
tp.tpf_update_time[name] = true
return
end

Expand Down