Harmonize function names with snake case

This commit is contained in:
Athozus 2024-03-22 22:43:26 +01:00
parent 6f7ccc77bd
commit 1c5e4b6cd6
No known key found for this signature in database
GPG Key ID: B50895022E8484BF
9 changed files with 19 additions and 19 deletions

View File

@ -34,14 +34,14 @@ function mail.send(m)
-- normalize to, cc and bcc while compiling a list of all recipients -- normalize to, cc and bcc while compiling a list of all recipients
local recipients = {} local recipients = {}
local undeliverable = {} local undeliverable = {}
m.to = mail.concat_player_list(mail.extractMaillists(m.to, m.from)) m.to = mail.concat_player_list(mail.extract_maillists(m.to, m.from))
m.to = mail.normalize_players_and_add_recipients(m.from, m.to, recipients, undeliverable) m.to = mail.normalize_players_and_add_recipients(m.from, m.to, recipients, undeliverable)
if m.cc then if m.cc then
m.cc = mail.concat_player_list(mail.extractMaillists(m.cc, m.from)) m.cc = mail.concat_player_list(mail.extract_maillists(m.cc, m.from))
m.cc = mail.normalize_players_and_add_recipients(mail.from, m.cc, recipients, undeliverable) m.cc = mail.normalize_players_and_add_recipients(mail.from, m.cc, recipients, undeliverable)
end end
if m.bcc then if m.bcc then
m.bcc = mail.concat_player_list(mail.extractMaillists(m.bcc, m.from)) m.bcc = mail.concat_player_list(mail.extract_maillists(m.bcc, m.from))
m.bcc = mail.normalize_players_and_add_recipients(m.from, m.bcc, recipients, undeliverable) m.bcc = mail.normalize_players_and_add_recipients(m.from, m.bcc, recipients, undeliverable)
end end

View File

@ -431,7 +431,7 @@ local function extract_maillists_main(receivers, maillists_owner, expanded_recei
end end
end end
function mail.extractMaillists(receivers, maillists_owner) function mail.extract_maillists(receivers, maillists_owner)
local expanded_receivers = {} local expanded_receivers = {}
extract_maillists_main(receivers, maillists_owner, expanded_receivers, {}) extract_maillists_main(receivers, maillists_owner, expanded_receivers, {})
return expanded_receivers return expanded_receivers
@ -478,7 +478,7 @@ function mail.reset_settings(playername)
mail.set_storage_entry(playername, entry) mail.set_storage_entry(playername, entry)
end end
function mail.pairsByKeys(t, f) function mail.pairs_by_keys(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

@ -27,7 +27,7 @@ minetest.register_on_player_receive_fields(function(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, _, i in mail.pairsByKeys(contacts) do for k, _, i in mail.pairs_by_keys(contacts) do
if i == evt.row - 1 then if i == evt.row - 1 then
mail.selected_idxs.contacts[name] = tonumber(k) mail.selected_idxs.contacts[name] = tonumber(k)
break break
@ -58,7 +58,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
-- except if it was the last. Then determine the new last -- 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 in mail.pairsByKeys(contacts) do for k in mail.pairs_by_keys(contacts) do
if found then if found then
mail.selected_idxs.contacts[name] = tonumber(k) mail.selected_idxs.contacts[name] = tonumber(k)
break break

View File

@ -1,6 +1,6 @@
-- Getter to filter and sort messages on demand -- Getter to filter and sort messages on demand
local function messageGetter(messages, sortfield, ascending, filter) local function message_getter(messages, sortfield, ascending, filter)
local results local results
return function() return function()
if not results then if not results then
@ -54,8 +54,8 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
local entry = mail.get_storage_entry(name) local entry = mail.get_storage_entry(name)
local messagesDrafts = entry.drafts local messagesDrafts = entry.drafts
local messagesTrash = entry.trash local messagesTrash = entry.trash
local getInbox = messageGetter(entry.inbox, inboxsortfield, sortdirection == "2", filter) local getInbox = message_getter(entry.inbox, inboxsortfield, sortdirection == "2", filter)
local getOutbox = messageGetter(entry.outbox, outboxsortfield, sortdirection == "2", filter) local getOutbox = message_getter(entry.outbox, outboxsortfield, sortdirection == "2", filter)
-- Hanmdle formspec event -- Hanmdle formspec event
if fields.inbox then -- inbox table if fields.inbox then -- inbox table

View File

@ -85,7 +85,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
-- except if it was the last. Then determine the new last -- 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 in mail.pairsByKeys(maillists) do for k in mail.pairs_by_keys(maillists) do
if found then if found then
mail.selected_idxs.maillists[name] = k mail.selected_idxs.maillists[name] = k
break break

View File

@ -3,7 +3,7 @@ local S = minetest.get_translator("mail")
local FORMNAME = "mail:message" local FORMNAME = "mail:message"
local function interleaveMsg(body) local function interleave_msg(body)
return "> " .. (body or ""):gsub("\n", "\n> ") return "> " .. (body or ""):gsub("\n", "\n> ")
end end
@ -78,7 +78,7 @@ function mail.reply(name, message)
minetest.log("error", "[mail] current mail-context: " .. dump(mail.selected_idxs)) minetest.log("error", "[mail] current mail-context: " .. dump(mail.selected_idxs))
return return
end end
mail.show_compose(name, message.from, "Re: "..message.subject, interleaveMsg(message.body)) mail.show_compose(name, message.from, "Re: "..message.subject, interleave_msg(message.body))
end end
function mail.replyall(name, message) function mail.replyall(name, message)
@ -113,11 +113,11 @@ function mail.replyall(name, message)
end end
cc = mail.concat_player_list(cc) cc = mail.concat_player_list(cc)
mail.show_compose(name, recipients, "Re: "..message.subject, interleaveMsg(message.body), cc) mail.show_compose(name, recipients, "Re: "..message.subject, interleave_msg(message.body), cc)
end end
function mail.forward(name, message) function mail.forward(name, message)
mail.show_compose(name, "", "Fw: " .. (message.subject or ""), interleaveMsg(message.body)) mail.show_compose(name, "", "Fw: " .. (message.subject or ""), interleave_msg(message.body))
end end
minetest.register_on_player_receive_fields(function(player, formname, fields) minetest.register_on_player_receive_fields(function(player, formname, fields)

View File

@ -75,7 +75,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
if fields[v.."add"] then if fields[v.."add"] then
update = true update = true
if mail.selected_idxs.contacts[name] then if mail.selected_idxs.contacts[name] then
for k, contact, i in mail.pairsByKeys(contacts) do for k, contact, i in mail.pairs_by_keys(contacts) do
if k == mail.selected_idxs.contacts[name] or i == mail.selected_idxs.contacts[name] then if k == mail.selected_idxs.contacts[name] or i == mail.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

View File

@ -27,7 +27,7 @@ local function rgb2hex(rgb)
return "#" .. string.format("%x", rgb.r) .. string.format("%x", rgb.g) .. string.format("%x", rgb.b) return "#" .. string.format("%x", rgb.r) .. string.format("%x", rgb.g) .. string.format("%x", rgb.b)
end end
local function rgbColorsMix(colors) local function rgb_colors_mix(colors)
local R = 0 local R = 0
local G = 0 local G = 0
local B = 0 local B = 0
@ -52,7 +52,7 @@ function mail.get_color(mix)
for _, c in ipairs(mix) do for _, c in ipairs(mix) do
colors2mix[#colors2mix+1] = hex2rgb(get_base_color(c)) colors2mix[#colors2mix+1] = hex2rgb(get_base_color(c))
end end
local mixed_color = rgbColorsMix(colors2mix) local mixed_color = rgb_colors_mix(colors2mix)
return rgb2hex(mixed_color) return rgb2hex(mixed_color)
end end
end end

View File

@ -8,7 +8,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 mail.pairsByKeys(contacts) do for k, contact, i, l in mail.pairs_by_keys(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] = ","