1 --[[ This is the doc_items example.
2 This example shows how to add help texts to items and how to use
3 other frequently-used features of doc_items.
6 --[[ IMPORTANT REMINDER: doc_items mod will automatically generate help
7 entries for all items (a few exceptions apply) without your intervention.
8 doc_items already extracts a lot of item definition automatically.
9 The API is mainly concernd about enhancing the existing item entries.
11 Hint: When using this example, use the `/help_reveal`
12 chat command to reveal all item entries (for testing) ]]
16 -- For nontrivial items, you typically want to use the _doc_items_* fields
17 minetest
.register_craftitem("doc_example:item1", {
18 description
= "doc_example test item 1",
19 -- This is the typical way to add extended item descriptions.
20 _doc_items_longdesc
= "This is an useless example item. It does nothing.",
21 -- This simple item is self-explanatory, so we can omit _doc_items_usagehelp
22 -- For more fields, see API.md of doc_items
24 -- Just an example group
25 group
= { example
= 1 },
28 -- These are just more example items which we use for the factoids later
29 minetest
.register_craftitem("doc_example:item2", {
30 description
= "doc_example test item 2",
31 group
= { example
= 2 },
34 minetest
.register_craftitem("doc_example:item3", {
35 description
= "doc_example test item 3",
36 group
= { example
= 25 },
39 minetest
.register_tool("doc_example:tool", {
40 description
= "doc_example chat tool",
41 _doc_items_longdesc
= "This tool is able to write something into the chat.",
42 -- This tool has an unique non-standard use (i.e. not mining, not melee combat, etc.), so we should add this field as well
43 -- Read API.md of doc_items for guidelines to write good help texts
44 _doc_items_usagehelp
= "Punch to send a chat message.",
45 -- The tool entry will be visible for everyone at start
46 _doc_items_hidden
= false,
48 minetest
.chat_send_all("The doc_example chat tool has been used!")
53 Reminder: A factoid is an automatically generated text based on the item definition.
54 This section will demonstrate the use of factoids
57 -- This adds an automatically generated text for all items which are a member of the example group
58 doc
.sub
.items
.register_factoid("craftitems", "groups", function(category_id
, def
)
59 if def
.groups
.example
then
60 return string.format("Example factoid: This item is member of the example group at rating %d.", def
.groups
.example
)
66 -- This factoid adds the drawtype for nodes
67 doc
.sub
.items
.register_factoid("nodes", "misc", function(category_id
, def
)
68 return string.format("Example factoid: This item has the drawtype ā%sā.", def
.drawtype
)