Minetest-WorldEditAdditions/worldeditadditions/utils/tables/table_get_last.lua
Starbeamrainbowlabs db7b20d485
Refactor table functions into subtable of wea
Also, you can return a value from dofile()!!!!

This changes everything.
2021-06-28 00:56:29 +01:00

17 lines
538 B
Lua

local wea = worldeditadditions
local table_unpack = dofile(wea.modpath.."/utils/tables/table_unpack.lua")
--- Returns only the last count items in a given numerical table-based list.
-- @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(
tbl,
math.max(0, (#tbl) - (count - 1))
)}
end
return table_get_last