mirror of
https://github.com/mt-mods/mail.git
synced 2025-04-30 08:21:44 -04:00
Use table.copy() minetest api function
This commit is contained in:
parent
1ea13e77a3
commit
6b8ce291a2
1 changed files with 2 additions and 17 deletions
|
@ -3,21 +3,6 @@ local S = minetest.get_translator("mail")
|
||||||
|
|
||||||
local FORMNAME = "mail:settings"
|
local FORMNAME = "mail:settings"
|
||||||
|
|
||||||
local function deepcopy(orig)
|
|
||||||
local orig_type = type(orig)
|
|
||||||
local copy
|
|
||||||
if orig_type == 'table' then
|
|
||||||
copy = {}
|
|
||||||
for orig_key, orig_value in next, orig, nil do
|
|
||||||
copy[deepcopy(orig_key)] = deepcopy(orig_value)
|
|
||||||
end
|
|
||||||
setmetatable(copy, deepcopy(getmetatable(orig)))
|
|
||||||
else -- number, string, boolean, etc
|
|
||||||
copy = orig
|
|
||||||
end
|
|
||||||
return copy
|
|
||||||
end
|
|
||||||
|
|
||||||
function mail.show_settings(name)
|
function mail.show_settings(name)
|
||||||
local groups_labels = {}
|
local groups_labels = {}
|
||||||
local group_index = 1
|
local group_index = 1
|
||||||
|
@ -82,7 +67,7 @@ function mail.show_settings(name)
|
||||||
]]
|
]]
|
||||||
end
|
end
|
||||||
if data.dataset then
|
if data.dataset then
|
||||||
local formatted_dataset = deepcopy(data.dataset)
|
local formatted_dataset = table.copy(data.dataset)
|
||||||
if data.format then
|
if data.format then
|
||||||
for i, d in ipairs(formatted_dataset) do
|
for i, d in ipairs(formatted_dataset) do
|
||||||
formatted_dataset[i] = data.format(d)
|
formatted_dataset[i] = data.format(d)
|
||||||
|
@ -104,7 +89,7 @@ function mail.show_settings(name)
|
||||||
|
|
||||||
elseif data.type == "index" then
|
elseif data.type == "index" then
|
||||||
y = y + 0.55
|
y = y + 0.55
|
||||||
local formatted_dataset = deepcopy(data.dataset)
|
local formatted_dataset = table.copy(data.dataset)
|
||||||
if data.format then
|
if data.format then
|
||||||
for i, d in ipairs(formatted_dataset) do
|
for i, d in ipairs(formatted_dataset) do
|
||||||
formatted_dataset[i] = data.format(d)
|
formatted_dataset[i] = data.format(d)
|
||||||
|
|
Loading…
Add table
Reference in a new issue