From dbdbc54321031485fca8084dd3c867ca2f6bdd8e Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 16 Dec 2016 13:42:10 +0100 Subject: Automatically collect all crafting groups --- init.lua | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'init.lua') diff --git a/init.lua b/init.lua index 89b0f10..67c8ab8 100644 --- a/init.lua +++ b/init.lua @@ -52,7 +52,7 @@ local groups_to_string = function(grouptable, filter) local gstring = "" local groups_count = 0 for id, value in pairs(grouptable) do - if groupdefs[id] ~= nil and (filter == nil or filter[id] == true) then + if (filter == nil or filter[id] == true) then -- Readable group name if groups_count > 0 then -- List seperator @@ -1064,6 +1064,24 @@ local function gather_descs() end end + -- ... and gather all groups which appear in crafting recipes + for id, def in pairs(minetest.registered_items) do + local crafts = minetest.get_all_craft_recipes(id) + if crafts ~= nil then + for c=1,#crafts do + for k,v in pairs(crafts[c].items) do + if string.sub(v,1,6) == "group:" then + local groupstring = string.sub(v,7,-1) + local groups = string.split(groupstring, ",") + for g=1, #groups do + miscgroups[groups[g]] = true + end + end + end + end + end + end + -- 2nd pass: Add entries -- Set default air text -- cgit v1.2.3