mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2025-02-18 11:34:59 +01:00
Add helper functions to update/merge tables.
This commit is contained in:
parent
a7bc460fae
commit
fa22ec4dd0
1 changed files with 22 additions and 0 deletions
|
@ -1,5 +1,27 @@
|
||||||
mcl_util = {}
|
mcl_util = {}
|
||||||
|
|
||||||
|
-- Updates all values in t using values from to*.
|
||||||
|
function table.update(t, ...)
|
||||||
|
for _, to in ipairs{...} do
|
||||||
|
for k,v in pairs(to) do
|
||||||
|
t[k] = v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return t
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Updates nil values in t using values from to*.
|
||||||
|
function table.update_nil(t, ...)
|
||||||
|
for _, to in ipairs{...} do
|
||||||
|
for k,v in pairs(to) do
|
||||||
|
if t[k] == nil then
|
||||||
|
t[k] = v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return t
|
||||||
|
end
|
||||||
|
|
||||||
-- Based on minetest.rotate_and_place
|
-- Based on minetest.rotate_and_place
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
|
|
Loading…
Reference in a new issue