satisfy luacheck

This commit is contained in:
BuckarooBanzay 2020-10-13 19:20:18 +02:00
parent 63521f5e85
commit 51e80c6d9d
4 changed files with 21 additions and 16 deletions

29
gui.lua
View File

@ -152,7 +152,7 @@ function mail.show_edit_contact(name, contact_name, note, illegal_name_hint)
minetest.show_formspec(name, "mail:editcontact", formspec) minetest.show_formspec(name, "mail:editcontact", formspec)
end end
function mail.show_select_contact(name, to, cc, bcc) function mail.show_select_contact(name, to, cc)
local formspec = mail.select_contact_formspec local formspec = mail.select_contact_formspec
local contacts = mail.compile_contact_list(name, selected_idxs.contacts[name]) local contacts = mail.compile_contact_list(name, selected_idxs.contacts[name])
@ -183,7 +183,7 @@ function mail.compile_contact_list(name, selected, playernames)
if playernames == nil then if playernames == nil then
local length = 0 local length = 0
for k, contact, i, l in pairsByKeys(contacts) do for k, contact, i, l in mail.pairsByKeys(contacts) do
if i == 1 then length = l end if i == 1 then length = l end
formspec[#formspec + 1] = "," formspec[#formspec + 1] = ","
formspec[#formspec + 1] = "," formspec[#formspec + 1] = ","
@ -534,7 +534,7 @@ function mail.handle_receivefields(player, formname, fields)
if fields[v.."add"] then if fields[v.."add"] then
update = true update = true
if selected_idxs.contacts[name] then if selected_idxs.contacts[name] then
for k, contact, i in pairsByKeys(contacts) do for k, contact, i in mail.pairsByKeys(contacts) do
if k == selected_idxs.contacts[name] or i == selected_idxs.contacts[name] then if k == selected_idxs.contacts[name] or i == selected_idxs.contacts[name] then
local list = mail.parse_player_list(draft[v]) local list = mail.parse_player_list(draft[v])
list[#list+1] = contact.name list[#list+1] = contact.name
@ -565,10 +565,6 @@ function mail.handle_receivefields(player, formname, fields)
return true return true
end end
if fields.back then
-- just do the default stuff below, as ESC will
end
-- delete old idxs -- delete old idxs
for _,v in ipairs({"contacts","to","cc","bcc"}) do for _,v in ipairs({"contacts","to","cc","bcc"}) do
selected_idxs[v][name] = nil selected_idxs[v][name] = nil
@ -582,27 +578,36 @@ function mail.handle_receivefields(player, formname, fields)
if fields.contacts then if fields.contacts then
local evt = minetest.explode_table_event(fields.contacts) local evt = minetest.explode_table_event(fields.contacts)
for k,c,i in pairsByKeys(contacts) do for k, _, i in mail.pairsByKeys(contacts) do
if i == evt.row - 1 then if i == evt.row - 1 then
selected_idxs.contacts[name] = k selected_idxs.contacts[name] = k
break break
end end
end end
if evt.type == "DCL" and contacts[selected_idxs.contacts[name]] then if evt.type == "DCL" and contacts[selected_idxs.contacts[name]] then
mail.show_edit_contact(name, contacts[selected_idxs.contacts[name]].name, contacts[selected_idxs.contacts[name]].note) mail.show_edit_contact(
name,
contacts[selected_idxs.contacts[name]].name,
contacts[selected_idxs.contacts[name]].note
)
end end
return true return true
elseif fields.new then elseif fields.new then
selected_idxs.contacts[name] = "#NEW#" selected_idxs.contacts[name] = "#NEW#"
mail.show_edit_contact(name, "", "") mail.show_edit_contact(name, "", "")
elseif fields.edit then elseif fields.edit then
mail.show_edit_contact(name, contacts[selected_idxs.contacts[name]].name, contacts[selected_idxs.contacts[name]].note) mail.show_edit_contact(
name,
contacts[selected_idxs.contacts[name]].name,
contacts[selected_idxs.contacts[name]].note
)
elseif fields.delete then elseif fields.delete then
if contacts[selected_idxs.contacts[name]] then if contacts[selected_idxs.contacts[name]] then
-- delete the contact and set the selected to the next in the list, except if it was the last. Then determine the new last -- delete the contact and set the selected to the next in the list,
-- except if it was the last. Then determine the new last
local found = false local found = false
local last = nil local last = nil
for k,v,i in pairsByKeys(contacts) do for k in mail.pairsByKeys(contacts) do
if found then if found then
selected_idxs.contacts[name] = k selected_idxs.contacts[name] = k
break break

View File

@ -34,7 +34,7 @@ mail.migrate_contacts = function(playername)
local contacts = {} local contacts = {}
if messages and not contacts then if messages and not contacts then
for k,message in pairs(messages) do for _, message in pairs(messages) do
mail.ensure_new_format(message) mail.ensure_new_format(message)
if contacts[string.lower(message.from)] == nil then if contacts[string.lower(message.from)] == nil then
contacts[string.lower(message.from)] = { contacts[string.lower(message.from)] = {

View File

@ -36,7 +36,7 @@ mail.getContacts = function(playername)
return mail.read_json_file(mail.getContactsFile(playername)) return mail.read_json_file(mail.getContactsFile(playername))
end end
function pairsByKeys(t, f) function mail.pairsByKeys(t, f)
-- http://www.lua.org/pil/19.3.html -- http://www.lua.org/pil/19.3.html
local a = {} local a = {}
for n in pairs(t) do table.insert(a, n) end for n in pairs(t) do table.insert(a, n) end

View File

@ -4,7 +4,7 @@ and add individual player names to recipient list
--]] --]]
function mail.normalize_players_and_add_recipients(field, recipients) function mail.normalize_players_and_add_recipients(field, recipients)
local order = mail.parse_player_list(field) local order = mail.parse_player_list(field)
for i,c in ipairs(order) do for _, c in ipairs(order) do
if recipients[string.lower(c)] == nil then if recipients[string.lower(c)] == nil then
recipients[string.lower(c)] = c recipients[string.lower(c)] = c
end end
@ -40,7 +40,7 @@ function mail.player_in_list(name, list)
if type(list) == "string" then if type(list) == "string" then
list = mail.parse_player_list(list) list = mail.parse_player_list(list)
end end
for k,c in pairs(list) do for _, c in pairs(list) do
if name == c then if name == c then
return true return true
end end