Minetest-WorldEditAdditions/worldeditadditions/utils/tables/table_get_last.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

7 lines
225 B
Lua

--- Returns only the last count items in a given numerical table-based list.
function worldeditadditions.table_get_last(tbl, count)
return {worldeditadditions.table_unpack(
tbl,
math.max(0, (#tbl) - (count - 1))
)}
end