From 813b6e7fa38277bc84e94e5efca309758c87d759 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 16 Dec 2016 17:40:07 +0100 Subject: Automatically add connects_to groups to miscgroups --- API.md | 33 +++++++++++++++++---------------- init.lua | 10 ++++++++++ 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/API.md b/API.md index 5470ef8..9db38bf 100644 --- a/API.md +++ b/API.md @@ -254,34 +254,35 @@ returned. ### `doc.sub.items.add_notable_groups(groupnames)` Add a list of groups you think are notable enough to be mentioned in the -“This item belongs to the following groups: (…)” factoid. +“This item belongs to the following groups: (…)” factoid. This factoid +is intended to give a quick rundown of misc. groups which don't fit +to other factoids, yet they are still somewhat relevant to gameplay. `groupnames` is a table of group names. -Groups which are used for crafting are already automatically added. +Groups which are used for crafting or in the `connects_to` field of item +definitions are already automatically added to this factoid, so you can +omit those (but no harm is done if you do it anyway). -What is “notable” is subjective, but here's a rule of thumb you may follow: +What is “notable” is subjective, but there are some guidelines: -You should add groups with this function if: +You should add groups with this function if this group is somehow important +for interaction, interesting for the player and not already covered by the +other factoids. -* This group is somehow important for interaction -* This group appears in `connect_to` definitions of nodes +Note that most groups are probably already covered elsewhere, so you +probably only need to add a few groups here. -Do not add groups if: +Do not add a group if: -* This group is only used for crafting purposes (this is already covered) +* It is *only* used for crafting purposes (this is already covered) +* It *only* appears in `connect_to` definitions of nodes (this is covered, too) +* The group is a mining or damage group (this is covered, too) * The group is only used internally * The group is uninteresting for the player * A factoid covering this group already exists * Writing a factoid would be more useful -* The group is a mining or damage group -* Rating is important to gameplay (consider writing a factoid instead) - -The intention of this function is to give a short rundown of the groups -which are notable as they are important to gameplay in some way yet don't -deserve a full-blown factoid. - - +* Group rating is important to gameplay (consider writing a factoid instead) ## Dependencies If you only add the custom fields to your items, you do *not* need to depend diff --git a/init.lua b/init.lua index e7a1142..19052a0 100644 --- a/init.lua +++ b/init.lua @@ -1078,6 +1078,16 @@ local function gather_descs() end end end + + -- ... and gather all groups used in connects_to + if def.connects_to ~= nil then + for c=1, #def.connects_to do + if string.sub(def.connects_to[c],1,6) == "group:" then + local group = string.sub(def.connects_to[c],7,-1) + miscgroups[group] = true + end + end + end end -- 2nd pass: Add entries -- cgit v1.2.3