mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-12-11 08:23:19 +01:00
1f44e240fb
..it was getting rather long, because Lua doesn't exactly come with batteries included :-/
19 lines
438 B
Lua
19 lines
438 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.
|
|
function worldeditadditions.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
|