Continuing to implement new steering, removed common.txt, inside functions have been moved to separate files

This commit is contained in:
Иван Грачёв
2021-03-26 22:42:51 +05:00
parent 2f8c949776
commit 5c854e183b
6 changed files with 91 additions and 49 deletions

View File

@@ -0,0 +1 @@
NULL_ENTITY = entity(0)

View File

@@ -17,3 +17,28 @@ function table.chunk(tbl, size)
return result
end
function table.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[table.deepcopy(orig_key)] = table.deepcopy(orig_value)
end
setmetatable(copy, table.deepcopy(getmetatable(orig)))
else -- number, string, boolean, etc
copy = orig
end
return copy
end
function table.merge(table1, table2)
local newTable = table.deepcopy(table1)
for k, v in pairs(table2) do
newTable[k] = v
end
return newTable
end