Minetest-WorldEditAdditions/worldeditadditions/utils/tables/table_unpack.lua
Starbeamrainbowlabs 1f44e240fb
utils/tables: refactor into separate files
..it was getting rather long, because Lua doesn't exactly come with 
batteries included :-/
2021-06-03 01:57:46 +01:00

13 lines
428 B
Lua

--- Polyfill for unpack / table.unpack.
-- Calls unpack when available, and looks for table.unpack if unpack() isn't
-- found.
-- This is needed because in Lua 5.1 it's the global unpack(), but in Lua 5.4
-- it's moved to table.unpack().
function worldeditadditions.table_unpack(tbl, offset, count)
if type(unpack) == "function" then
return unpack(tbl, offset, count)
else
return table.unpack(tbl, offset, count)
end
end