2022-09-18 18:32:13 +02:00
|
|
|
local wea_c = worldeditadditions_core
|
2021-06-28 01:56:29 +02:00
|
|
|
|
2022-09-24 14:41:44 +02:00
|
|
|
local table_unpack = dofile(wea_c.modpath.."/utils/table/table_unpack.lua")
|
2021-06-28 01:56:29 +02:00
|
|
|
|
|
|
|
|
2021-06-03 02:57:46 +02:00
|
|
|
--- Returns only the last count items in a given numerical table-based list.
|
2021-06-28 01:56:29 +02:00
|
|
|
-- @param tbl table The table to fetch items from.
|
|
|
|
-- @param count number The number of items to fetch from the end of the table.
|
|
|
|
-- @returns table A table containing the last count items from the given table.
|
|
|
|
local function table_get_last(tbl, count)
|
|
|
|
return {table_unpack(
|
2021-06-03 02:57:46 +02:00
|
|
|
tbl,
|
|
|
|
math.max(0, (#tbl) - (count - 1))
|
|
|
|
)}
|
|
|
|
end
|
2021-06-28 01:56:29 +02:00
|
|
|
|
|
|
|
return table_get_last
|