From 1c5e4b6cd684371547f434e3511b9f05a3b4d7c9 Mon Sep 17 00:00:00 2001 From: Athozus Date: Fri, 22 Mar 2024 22:43:26 +0100 Subject: [PATCH] Harmonize function names with snake case --- api.lua | 6 +++--- storage.lua | 4 ++-- ui/contacts.lua | 4 ++-- ui/events.lua | 6 +++--- ui/maillists.lua | 2 +- ui/message.lua | 8 ++++---- ui/select_contact.lua | 2 +- util/colors.lua | 4 ++-- util/contact.lua | 2 +- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/api.lua b/api.lua index 541063f..8da15f3 100644 --- a/api.lua +++ b/api.lua @@ -34,14 +34,14 @@ function mail.send(m) -- normalize to, cc and bcc while compiling a list of all recipients local recipients = {} 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) 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) end 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) end diff --git a/storage.lua b/storage.lua index e9e5e77..de7342c 100644 --- a/storage.lua +++ b/storage.lua @@ -431,7 +431,7 @@ local function extract_maillists_main(receivers, maillists_owner, expanded_recei end end -function mail.extractMaillists(receivers, maillists_owner) +function mail.extract_maillists(receivers, maillists_owner) local expanded_receivers = {} extract_maillists_main(receivers, maillists_owner, expanded_receivers, {}) return expanded_receivers @@ -478,7 +478,7 @@ function mail.reset_settings(playername) mail.set_storage_entry(playername, entry) end -function mail.pairsByKeys(t, f) +function mail.pairs_by_keys(t, f) -- http://www.lua.org/pil/19.3.html local a = {} for n in pairs(t) do table.insert(a, n) end diff --git a/ui/contacts.lua b/ui/contacts.lua index a56af7f..2b1a7d5 100644 --- a/ui/contacts.lua +++ b/ui/contacts.lua @@ -27,7 +27,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) if fields.contacts then 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 mail.selected_idxs.contacts[name] = tonumber(k) 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 local found = false local last = nil - for k in mail.pairsByKeys(contacts) do + for k in mail.pairs_by_keys(contacts) do if found then mail.selected_idxs.contacts[name] = tonumber(k) break diff --git a/ui/events.lua b/ui/events.lua index 4d975e4..2686c9d 100644 --- a/ui/events.lua +++ b/ui/events.lua @@ -1,6 +1,6 @@ -- 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 return function() 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 messagesDrafts = entry.drafts local messagesTrash = entry.trash - local getInbox = messageGetter(entry.inbox, inboxsortfield, sortdirection == "2", filter) - local getOutbox = messageGetter(entry.outbox, outboxsortfield, sortdirection == "2", filter) + local getInbox = message_getter(entry.inbox, inboxsortfield, sortdirection == "2", filter) + local getOutbox = message_getter(entry.outbox, outboxsortfield, sortdirection == "2", filter) -- Hanmdle formspec event if fields.inbox then -- inbox table diff --git a/ui/maillists.lua b/ui/maillists.lua index 31e55f3..f8b0522 100644 --- a/ui/maillists.lua +++ b/ui/maillists.lua @@ -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 local found = false local last = nil - for k in mail.pairsByKeys(maillists) do + for k in mail.pairs_by_keys(maillists) do if found then mail.selected_idxs.maillists[name] = k break diff --git a/ui/message.lua b/ui/message.lua index d5f7257..3cb0e4c 100644 --- a/ui/message.lua +++ b/ui/message.lua @@ -3,7 +3,7 @@ local S = minetest.get_translator("mail") local FORMNAME = "mail:message" -local function interleaveMsg(body) +local function interleave_msg(body) return "> " .. (body or ""):gsub("\n", "\n> ") end @@ -78,7 +78,7 @@ function mail.reply(name, message) minetest.log("error", "[mail] current mail-context: " .. dump(mail.selected_idxs)) return 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 function mail.replyall(name, message) @@ -113,11 +113,11 @@ function mail.replyall(name, message) end 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 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 minetest.register_on_player_receive_fields(function(player, formname, fields) diff --git a/ui/select_contact.lua b/ui/select_contact.lua index 03cfa13..42a5071 100644 --- a/ui/select_contact.lua +++ b/ui/select_contact.lua @@ -75,7 +75,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) if fields[v.."add"] then update = true 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 local list = mail.parse_player_list(draft[v]) list[#list+1] = contact.name diff --git a/util/colors.lua b/util/colors.lua index adc9aa4..fa39af6 100644 --- a/util/colors.lua +++ b/util/colors.lua @@ -27,7 +27,7 @@ local function rgb2hex(rgb) return "#" .. string.format("%x", rgb.r) .. string.format("%x", rgb.g) .. string.format("%x", rgb.b) end -local function rgbColorsMix(colors) +local function rgb_colors_mix(colors) local R = 0 local G = 0 local B = 0 @@ -52,7 +52,7 @@ function mail.get_color(mix) for _, c in ipairs(mix) do colors2mix[#colors2mix+1] = hex2rgb(get_base_color(c)) end - local mixed_color = rgbColorsMix(colors2mix) + local mixed_color = rgb_colors_mix(colors2mix) return rgb2hex(mixed_color) end end diff --git a/util/contact.lua b/util/contact.lua index 80792b4..763558f 100644 --- a/util/contact.lua +++ b/util/contact.lua @@ -8,7 +8,7 @@ function mail.compile_contact_list(name, selected, playernames) if playernames == nil then 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 formspec[#formspec + 1] = "," formspec[#formspec + 1] = ","