added sets.lua, reordered dofiles in /tables/init.luas

This commit is contained in:
VorTechnix 2021-06-02 19:18:49 -07:00
parent 38335e291f
commit 0026bcdab7
2 changed files with 14 additions and 4 deletions

@ -10,11 +10,12 @@
-- TODO: Refactor into its own worldeditadditions.tables namespace. -- TODO: Refactor into its own worldeditadditions.tables namespace.
dofile(worldeditadditions.modpath.."/utils/tables/sets.lua")
dofile(worldeditadditions.modpath.."/utils/tables/shallowcopy.lua") dofile(worldeditadditions.modpath.."/utils/tables/shallowcopy.lua")
dofile(worldeditadditions.modpath.."/utils/tables/table_apply.lua") dofile(worldeditadditions.modpath.."/utils/tables/table_apply.lua")
dofile(worldeditadditions.modpath.."/utils/tables/table_unpack.lua")
dofile(worldeditadditions.modpath.."/utils/tables/table_get_last.lua")
dofile(worldeditadditions.modpath.."/utils/tables/table_tostring.lua")
dofile(worldeditadditions.modpath.."/utils/tables/table_map.lua")
dofile(worldeditadditions.modpath.."/utils/tables/table_filter.lua") dofile(worldeditadditions.modpath.."/utils/tables/table_filter.lua")
dofile(worldeditadditions.modpath.."/utils/tables/table_get_last.lua")
dofile(worldeditadditions.modpath.."/utils/tables/table_map.lua")
dofile(worldeditadditions.modpath.."/utils/tables/table_tostring.lua")
dofile(worldeditadditions.modpath.."/utils/tables/table_unique.lua") dofile(worldeditadditions.modpath.."/utils/tables/table_unique.lua")
dofile(worldeditadditions.modpath.."/utils/tables/table_unpack.lua")

@ -0,0 +1,9 @@
--- Creates a table that stores data in keys.
-- @source https://riptutorial.com/lua/example/13407/search-for-an-item-in-a-list
-- @param list table The table of values to convert to keys.
-- @return table The table of (key,true) pairs.
function worldeditadditions.makeset (list)
local set = {}
for _, l in ipairs(list) do set[l] = true end
return set
end