From f36ed19df39c7f59c8cc99b8074bc5e4252ab3b9 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 9 Dec 2016 07:04:34 +0100 Subject: Allow category_id in register_factoid to be nil --- API.md | 1 + init.lua | 11 ++++------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/API.md b/API.md index 2731710..2ac6a34 100644 --- a/API.md +++ b/API.md @@ -224,6 +224,7 @@ Add a custom factoid (see above) for the specified category. * `"nodes"`: Blocks * `"tools"`: Tools and weapons * `"craftitems"`: Misc. items + * `nil`: All of the above * `factoid_type`: Rough categorization of the factoid's content. Controls where in the text the factoid appears. Possible values: * `"groups"`: Factoid appears near groups diff --git a/init.lua b/init.lua index 45121df..4ba6f88 100644 --- a/init.lua +++ b/init.lua @@ -270,16 +270,13 @@ end function doc.sub.items.register_factoid(category_id, factoid_type, factoid_generator) local ftable = { fgen = factoid_generator, ftype = factoid_type } - if category_id == "nodes" then - table.insert(factoid_generators.nodes, ftable) + if category_id == "nodes" or category_id == "tools" or category_id == "craftitems" then + table.insert(factoid_generators[category_id], ftable) return true - elseif category_id == "tools" then + elseif category_id == nil then + table.insert(factoid_generators.nodes, ftable) table.insert(factoid_generators.tools, ftable) - return true - elseif category_id == "craftitems" then table.insert(factoid_generators.craftitems, ftable) - return true - else return false end end -- cgit v1.2.3