diff --git a/basis/lib.lua b/basis/lib.lua index d47f5ac..6bf49dc 100644 --- a/basis/lib.lua +++ b/basis/lib.lua @@ -244,6 +244,17 @@ function techage.add_to_set(set, x) end end +-- techage.tbl_filter({"a", "b", "c", "d"}, function(v, k, t) return v >= "c" end) --> {"c","d"} +techage.tbl_filter = function(t, filterIter) + local out = {} + + for k, v in pairs(t) do + if filterIter(v, k, t) then out[k] = v end + end + + return out +end + function techage.get_node_lvm(pos) local node = minetest.get_node_or_nil(pos) if node then diff --git a/fusion_reactor/controller.lua b/fusion_reactor/controller.lua index 848cdaf..8af0bd8 100644 --- a/fusion_reactor/controller.lua +++ b/fusion_reactor/controller.lua @@ -46,6 +46,7 @@ local function count_trues(t) end local function nucleus(t) + t = techage.tbl_filter(t, function(v, k, t) return type(v) == "table" end) if #t == 4 then if vector.equals(t[1], t[2]) and vector.equals(t[3], t[4]) then return true