Harmonize function names with snake case
This commit is contained in:
parent
6f7ccc77bd
commit
1c5e4b6cd6
6
api.lua
6
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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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] = ","
|
||||
|
Loading…
x
Reference in New Issue
Block a user