diff --git a/README.md b/README.md index 07db3b3..55ca355 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ of the entire help. It includes examples for the following mods: * `doc_items`: In `doc_items.lua`, for item help. Start here! +* `doc_identifier`: In `doc_identifier.lua`, for adding lookup tool support for custom entities * `doc`: In `doc.lua`, for adding your own categories. For advanced modding Activate this mod in your world to see some example categories, entries and items added. diff --git a/depends.txt b/depends.txt index 93440a2..77d125a 100644 --- a/depends.txt +++ b/depends.txt @@ -1,2 +1,3 @@ doc doc_items +doc_identifier diff --git a/doc.lua b/doc.lua index 315d529..972a9dc 100644 --- a/doc.lua +++ b/doc.lua @@ -8,7 +8,7 @@ categories. ]] -- Let's start with a very simple text-based category --- This category only contains simple +-- This category only contains simple text doc.new_category("example1", { -- This is for humans and mandatory name = "Text Example", @@ -17,14 +17,20 @@ doc.new_category("example1", { -- Reminder: build_formspec determines how the entry data will be presented to the user }) --- Entry for the aforementioned category. We only add 1 entry +-- Entry for the aforementioned category. We add 2 entries doc.new_entry("example1", "text", { - -- This is for humans and mandatory + -- This is for the entry title in the user interface, it's mandatory name = "Text example", -- For this category, the entry data is simply the text to be displayed data = "Lorem Minetest dolor sit amet. Bla bla bla bla Minetest bla bla bla bla Mese bla. Bla bla bla bla bla, celeron55 bla bla, bla.", }) +-- We will use this entry in doc_identifier.lua +doc.new_entry("example1", "entity", { + name = "Entity entry", + data = "This is the entry for the entity (added in doc_identifier.lua). The example entity is just a boring cube which floats in the air. Punch it to destroy it.", +}) + ------------------------------------------------------------------------------- -- Category with hidden entry. diff --git a/doc_identifier.lua b/doc_identifier.lua new file mode 100644 index 0000000..49c3375 --- /dev/null +++ b/doc_identifier.lua @@ -0,0 +1,22 @@ +-- Example for using doc_identifier (Lookup Tool) +-- NOTE: Use the API to make custom entities identifiable by the lookup tool. +-- If you do not define any custom entities, using the API is not needed. +-- This example adds one example entity and adds doc_identifier support for it. + +-- To spawn this entity, use the chat command “/spawnentity doc_example:entity” +minetest.register_entity("doc_example:entity", { + physical = true, + collide_with_objects = true, + visual = "cube", + size = { x = 0.2, y = 0.2, z = 0.2 }, + textures = {"unknown_object.png", "unknown_object.png", "unknown_object.png", "unknown_object.png", "unknown_object.png", "unknown_object.png"}, + hp_max = 1, +}) + +--[[ This is the actual code you need to add doc_identifier support. +The following code means, whenever you use the lookup tool on the example entity, +the entry “entity” in category “example1” will be shown. ]] +doc.sub.identifier.register_object("doc_example:entity", "example1", "entity") + +--[[ NOTE: If you don't do this, the lookup tool will show an error message when +you use it on this entity. ]] diff --git a/doc_items.lua b/doc_items.lua index 6892771..3642102 100644 --- a/doc_items.lua +++ b/doc_items.lua @@ -59,12 +59,3 @@ doc.sub.items.register_factoid("nodes", "misc", function(category_id, def) return string.format("Example factoid: This item has the drawtype “%s”.", def.drawtype) end) --- This factoid adds the drawtype for nodes -doc.sub.items.register_factoid("nodes", "misc", function(category_id, def) - return string.format("Example factoid: This item has the drawtype “%s”.", def.drawtype) -end) - --- This factoid adds the drawtype for nodes -doc.sub.items.register_factoid("nodes", "misc", function(category_id, def) - return string.format("Example factoid: This item has the drawtype “%s”.", def.drawtype) -end) diff --git a/init.lua b/init.lua index e9eee64..370fcf8 100644 --- a/init.lua +++ b/init.lua @@ -1,2 +1,3 @@ dofile(minetest.get_modpath("doc_example").."/doc.lua") dofile(minetest.get_modpath("doc_example").."/doc_items.lua") +dofile(minetest.get_modpath("doc_example").."/doc_identifier.lua")