2021-06-03 00:57:46 +00:00
|
|
|
--- 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().
|
2021-06-27 23:56:29 +00:00
|
|
|
local function table_unpack(tbl, offset, count)
|
2022-09-17 22:42:46 +00:00
|
|
|
---@diagnostic disable-next-line: deprecated
|
2021-06-03 00:57:46 +00:00
|
|
|
if type(unpack) == "function" then
|
2022-09-17 22:42:46 +00:00
|
|
|
---@diagnostic disable-next-line: deprecated
|
2021-06-03 00:57:46 +00:00
|
|
|
return unpack(tbl, offset, count)
|
|
|
|
else
|
|
|
|
return table.unpack(tbl, offset, count)
|
|
|
|
end
|
|
|
|
end
|
2021-06-27 23:56:29 +00:00
|
|
|
|
|
|
|
return table_unpack
|