summaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
authorWuzzy <almikes@aol.com>2016-08-02 16:27:01 +0200
committerWuzzy <almikes@aol.com>2016-08-02 16:27:01 +0200
commit4e24394d41deef53633243fffad49652b0baa4f3 (patch)
tree4e931427a9352bef5d84ede6c9acf98ee8fcb9d5 /init.lua
parentc1e7ed29841aa55c31727e5d4d1af85b537cffa1 (diff)
Add basic factoid registration system
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua30
1 files changed, 28 insertions, 2 deletions
diff --git a/init.lua b/init.lua
index acb5d13..1298716 100644
--- a/init.lua
+++ b/init.lua
@@ -1,3 +1,5 @@
+doc.sub.items = {}
+
local groupdefs = {}
local minegroups = {}
local damagegroups= {}
@@ -106,6 +108,26 @@ local toolcaps_to_text = function(tool_capabilities)
return formstring
end
+local factoid_generators = {}
+factoid_generators.nodes = {}
+factoid_generators.tools = {}
+factoid_generators.craftitems = {}
+
+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)
+ return true
+ elseif category_id == "tools" then
+ 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
doc.new_category("nodes", {
name = "Blocks",
@@ -260,7 +282,11 @@ doc.new_category("nodes", {
end
formstring = formstring .. "\n"
- -- TODO: Insert custom group-based factoids here
+ -- Custom factoids are inserted here
+ for i=1,#factoid_generators.nodes do
+ formstring = formstring .. factoid_generators.nodes[i].fgen(data.itemstring, data.def)
+ formstring = formstring .. "\n"
+ end
-- Show other “exposable” groups in quick list
local gstring, gcount = groups_to_string(data.def.groups)
@@ -495,7 +521,6 @@ doc.new_category("craftitems", {
end
})
-doc.sub.items = {}
doc.sub.items.help = {}
doc.sub.items.help.longdesc = {}
doc.sub.items.help.usagehelp = {}
@@ -547,6 +572,7 @@ function doc.sub.items.add_item_name_overrides(itemstrings)
end
end
+
local function gather_descs()
local help = doc.sub.items.help
doc.new_entry("nodes", "air", {