Continuing to implement new steering, removed common.txt, inside functions have been moved to separate files
This commit is contained in:
1
koptilnya/libs/constants.txt
Normal file
1
koptilnya/libs/constants.txt
Normal file
@@ -0,0 +1 @@
|
||||
NULL_ENTITY = entity(0)
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user