mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-10-31 21:33:02 +00:00
Starbeamrainbowlabs
db7b20d485
Also, you can return a value from dofile()!!!! This changes everything.
17 lines
538 B
Lua
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
|