Add doc_identifier example
This commit is contained in:
parent
2edf7d7f68
commit
659bcf5501
@ -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.
|
||||
|
@ -1,2 +1,3 @@
|
||||
doc
|
||||
doc_items
|
||||
doc_identifier
|
||||
|
12
doc.lua
12
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.
|
||||
|
22
doc_identifier.lua
Normal file
22
doc_identifier.lua
Normal file
@ -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. ]]
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user