Minetest-WorldEditAdditions/worldeditadditions/utils/tables/table_unpack.lua

17 lines
529 B
Lua
Raw Normal View History

--- 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().
local function table_unpack(tbl, offset, count)
2022-09-18 00:42:46 +02:00
---@diagnostic disable-next-line: deprecated
if type(unpack) == "function" then
2022-09-18 00:42:46 +02:00
---@diagnostic disable-next-line: deprecated
return unpack(tbl, offset, count)
else
return table.unpack(tbl, offset, count)
end
end
return table_unpack