1 -- Disable built-in factoids; it is planned to add custom ones as replacements
2 doc
.sub
.items
.disable_core_factoid("node_mining")
3 doc
.sub
.items
.disable_core_factoid("tool_capabilities")
5 -- Help button callback
6 minetest
.register_on_player_receive_fields(function(player
, formname
, fields
)
7 if fields
.__mcl_doc
then
8 doc
.show_doc(player
:get_player_name())
15 doc
.sub
.items
.register_factoid("nodes", "drop_destroy", function(itemstring
, def
)
16 if def
.groups
.dig_by_water
then
17 return "Water can flow into this block and cause it to drop as an item."
23 doc
.sub
.items
.register_factoid("nodes", "groups", function(itemstring
, def
)
24 if def
.groups
.cultivatable
== 2 then
25 return "This block can be turned into dirt with a hoe."
26 elseif def
.groups
.cultivatable
== 2 then
27 return "This block can be turned into farmland with a hoe."
33 doc
.sub
.items
.register_factoid("nodes", "groups", function(itemstring
, def
)
35 if def
.groups
.soil_sapling
== 2 then
36 datastring
= datastring
.. "This block acts as a soil for all saplings." .. "\n"
37 elseif def
.groups
.soil_sapling
== 1 then
38 datastring
= datastring
.. "This block acts as a soil for some saplings." .. "\n"
40 if def
.groups
.soil_sugarcane
then
41 datastring
= datastring
.. "Sugar canes will grow on this block." .. "\n"
43 if def
.groups
.soil_nether_wart
then
44 datastring
= datastring
.. "Nether wart will grow on this block." .. "\n"
49 doc
.sub
.items
.register_factoid("nodes", "groups", function(itemstring
, def
)
51 if def
.groups
.leafdecay
~= nil then
52 if def
.drop
~= "" and def
.drop
~= nil and def
.drop
~= itemstring
then
53 formstring
= string.format("This block quickly decays when there is no wood block of any species within a distance of %d. When decaying, it disappears and may drop one of its regular drops. The block does not decay when the block has been placed by a player.", def
.groups
.leafdecay
)
55 formstring
= string.format("This block quickly decays and disappears when there is no wood block of any species within a distance of %d. The block does not decay when the block has been placed by a player.", def
.groups
.leafdecay
)
61 -- nodes which have flower placement rules
62 doc
.sub
.items
.register_factoid("nodes", "groups", function(itemstring
, def
)
64 if def
.groups
.place_flowerlike
== 1 then
65 return "This plant can only grow on grass blocks and dirt. To survive, it needs to have an unobstructed view to the sky above or be exposed to a light level of 8 or higher."
66 elseif def
.groups
.place_flowerlike
== 2 then
67 return "This plant can grow on grass blocks, podzol, dirt and coarse dirt. To survive, it needs to have an unobstructed view to the sky above or be exposed to a light level of 8 or higher."
73 doc
.sub
.items
.register_factoid("nodes", "groups", function(itemstring
, def
)
74 if def
.groups
.flammable
then
75 return "This block is flammable."
81 doc
.sub
.items
.register_factoid("nodes", "groups", function(itemstring
, def
)
82 if def
.groups
.destroys_items
then
83 return "This block destroys any item it touches."
90 doc
.sub
.items
.register_factoid(nil, "use", function(itemstring
, def
)
92 if def
.groups
.eatable
and not def
._doc_items_usagehelp
then
93 if def
.groups
.food
== 2 then
94 s
= s
.. "To eat it, wield it, then rightclick."
95 if def
.groups
.can_eat_when_full
== 1 then
96 s
= s
.. "\n" .. "You can eat this even when your hunger bar is full."
98 s
= s
.. "\n" .. "You cannot eat this when your hunger bar is full."
100 elseif def
.groups
.food
== 3 then
101 s
= s
.. "To drink it, wield it, then rightclick."
102 if def
.groups
.can_eat_when_full
~= 1 then
103 s
= s
.. "\n" .. "You cannot drink this when your hunger bar is full."
106 s
= s
.. "To consume it, wield it, then rightclick."
107 if def
.groups
.can_eat_when_full
~= 1 then
108 s
= s
.. "\n" .. "You cannot consume this when your hunger bar is full."
111 if def
.groups
.no_eat_delay
~= 1 then
112 s
= s
.. "\n" .. "You have to wait for about 2 seconds before you can eat or drink again."
118 doc
.sub
.items
.register_factoid(nil, "groups", function(itemstring
, def
)
120 if def
.groups
.eatable
and def
.groups
.eatable
> 0 then
121 s
= s
.. string.format("Hunger points restored: %d", def
.groups
.eatable
)
123 if def
._mcl_saturation
and def
._mcl_saturation
> 0 then
124 s
= s
.. "\n" .. string.format("Saturation points restored: %.1f", def
._mcl_saturation
)
129 -- TODO: Move this info to the crafting guide
130 doc
.sub
.items
.register_factoid(nil, "groups", function(itemstring
, def
)
131 if def
._repair_material
then
132 local mdef
= minetest
.registered_items
[def
._repair_material
]
134 if mdef
and mdef
.description
and mdef
.description
~= "" then
135 return string.format("This item can be repaired at an anvil with: %s.", mdef
.description
)
136 elseif def
._repair_material
== "group:wood" then
137 return "This item can be repaired at an anvil with any wooden planks."
138 elseif string.sub(def
._repair_material
, 1, 6) == "group:" then
139 local group
= string.sub(def
._repair_material
, 7)
140 return string.format("This item can be repaired at an anvil with any item in the “%s” group.", group
)
146 doc
.sub
.items
.register_factoid(nil, "groups", function(itemstring
, def
)
147 if minetest
.get_item_group(itemstring
, "no_rename") == 1 then
148 return "This item cannot be renamed at an anvil."
154 doc
.sub
.items
.register_factoid("nodes", "gravity", function(itemstring
, def
)
156 if minetest
.get_item_group(itemstring
, "crush_after_fall") == 1 then
157 s
= s
.. "This block crushes any block it falls into."
162 doc
.sub
.items
.register_factoid("nodes", "gravity", function(itemstring
, def
)
164 if minetest
.get_item_group(itemstring
, "crush_after_fall") == 1 then
165 s
= s
.. "When this block falls deeper than 1 block, it causes damage to any player it hits. The damage dealt is B×2−2 hit points with B = number of blocks fallen. The damage can never be more than 40 HP."
170 -- Mining, hardness and all that
171 doc
.sub
.items
.register_factoid("nodes", "mining", function(itemstring
, def
)
172 local pickaxey
= { "Diamond Pickaxe", "Iron Pickaxe", "Stone Pickaxe", "Golden Pickaxe", "Wooden Pickaxe" }
173 local axey
= { "Diamond Axe", "Iron Axe", "Stone Axe", "Golden Axe", "Wooden Axe" }
174 local shovely
= { "Diamond Shovel", "Iron Shovel", "Stone Shovel", "Golden Shovel", "Wooden Shovel" }
176 local datastring
= ""
177 local groups
= def
.groups
179 if groups
.dig_immediate
== 3 then
180 datastring
= datastring
.. "This block can be mined by any tool instantly." .. "\n"
182 local tool_minable
= false
184 if groups
.pickaxey
then
185 for g
=1, 6-groups
.pickaxey
do
186 datastring
= datastring
.. "• " .. pickaxey
[g
] .. "\n"
191 for g
=1, 6-groups
.axey
do
192 datastring
= datastring
.. "• " .. axey
[g
] .. "\n"
196 if groups
.shovely
then
197 for g
=1, 6-groups
.shovely
do
198 datastring
= datastring
.. "• " .. shovely
[g
] .. "\n"
202 if groups
.shearsy
or groups
.shearsy_wool
then
203 datastring
= datastring
.. "• Shears" .. "\n"
206 if groups
.swordy
or groups
.swordy_cobweb
then
207 datastring
= datastring
.. "• Sword" .. "\n"
211 datastring
= datastring
.. "• Hand" .. "\n"
216 datastring
= "This block can be mined by:\n" .. datastring
.. "\n"
220 local hardness
= def
._mcl_hardness
224 if hardness
== -1 then
225 datastring
= datastring
.. "Hardness: ∞"
227 datastring
= datastring
.. string.format("Hardness: %.2f", hardness
)
229 local blast
= def
._mcl_blast_resistance
233 -- TODO: Blast resistance as number
234 if blast
>= 1000 then
235 datastring
= datastring
.. "\n" .. "This block will not be destroyed by TNT explosions."
240 -- Special drops when mined by shears
241 doc
.sub
.items
.register_factoid("nodes", "drops", function(itemstring
, def
)
242 if def
._mcl_shears_drop
== true then
243 return "This block drops itself when mined by shears."
244 elseif type(def
._mcl_shears_drop
) == "table" then
246 for d
=1, #def
._mcl_shears_drop
do
247 local item
= ItemStack(def
._mcl_shears_drop
[d
])
248 local itemname
= item
:get_name()
249 local itemcount
= item
:get_count()
250 local idef
= minetest
.registered_items
[itemname
]
252 if idef
.description
and idef
.description
~= "" then
253 text
= idef
.description
257 if itemcount
> 1 then
258 text
= string.format("%d×%s", itemcount
, text
)
260 table.insert(drops
, text
)
262 local ret
= string.format("This blocks drops the following when mined by shears: %s", table.concat(drops
, ", "))