summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--API.md5
-rw-r--r--init.lua20
2 files changed, 21 insertions, 4 deletions
diff --git a/API.md b/API.md
index a054eb7..5470ef8 100644
--- a/API.md
+++ b/API.md
@@ -258,19 +258,18 @@ Add a list of groups you think are notable enough to be mentioned in the
`groupnames` is a table of group names.
-By default, no groups are shown for this factoid which means this factoid
-is never displayed.
+Groups which are used for crafting are already automatically added.
What is “notable” is subjective, but here's a rule of thumb you may follow:
You should add groups with this function if:
-* This group is used for crafting purposes
* This group is somehow important for interaction
* This group appears in `connect_to` definitions of nodes
Do not add groups if:
+* This group is only used for crafting purposes (this is already covered)
* The group is only used internally
* The group is uninteresting for the player
* A factoid covering this group already exists
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