diff --git a/data.lua b/data.lua index b8637ad..1732df6 100644 --- a/data.lua +++ b/data.lua @@ -2,28 +2,24 @@ -- Imports local lbn = require("lbn") -local table_len = lbn.util.table_len -local table_map = lbn.util.table_map -local table_values = lbn.util.table_values -local array_flatten = lbn.util.array_flatten -- Get all data modules to add local data_mods = { "entities", "hotkeys", "items", "recipies", "technologies" } -local data = table_map(data_mods, function(_, mod) +local data_to_add = lbn.util.array_map_table(data_mods, function(mod) return mod, require(("data.%s"):format(mod)) end) --- Log all data we got +-- Then add them all do - for name, table in pairs(data) do - log(("Found %i %s"):format(table_len(table), name)) + for name, arr in pairs(data_to_add) do + lbn.util.assert_array(arr) + + if settings.startup["lbn:log"].value then + log(("Adding %i %s: %s"):format(#arr, name, lbn.util.format_array(arr))) + end + + if #arr ~= 0 then + data:extend(arr) + end end end - --- Then flatten it to get all data -local all_data = array_flatten(table_values(data)) - --- Then, if not empty, add it all -if #all_data ~= 0 then - data:extend(all_data) -end