Minetest-WorldEditAdditions/worldeditadditions/utils/tables/shallowcopy.lua
Starbeamrainbowlabs db7b20d485
Refactor table functions into subtable of wea
Also, you can return a value from dofile()!!!!

This changes everything.
2021-06-28 00:56:29 +01:00

20 lines
445 B
Lua

--- Shallow clones a table.
-- @source http://lua-users.org/wiki/CopyTable
-- @param orig table The table to clone.
-- @return table The cloned table.
local function shallowcopy(orig)
local orig_type = type(orig)
local copy
if orig_type == 'table' then
copy = {}
for orig_key, orig_value in pairs(orig) do
copy[orig_key] = orig_value
end
else -- number, string, boolean, etc
copy = orig
end
return copy
end
return shallowcopy