Version 0.41.3
[MineClone/MineClone2/MineClone2-Fixes.git] / mods / HELP / mcl_doc / init.lua
blobb4f292b4cf755334b55bc0979e288ac560353f1d
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())
9 end
10 end)
12 -- doc_items factoids
14 -- dig_by_water
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."
18 end
19 return ""
20 end)
22 -- usable by hoes
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."
28 end
29 return ""
30 end)
32 -- soil
33 doc.sub.items.register_factoid("nodes", "groups", function(itemstring, def)
34 local datastring = ""
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"
39 end
40 if def.groups.soil_sugarcane then
41 datastring = datastring .. "Sugar canes will grow on this block." .. "\n"
42 end
43 if def.groups.soil_nether_wart then
44 datastring = datastring .. "Nether wart will grow on this block." .. "\n"
45 end
46 return datastring
47 end)
49 doc.sub.items.register_factoid("nodes", "groups", function(itemstring, def)
50 local formstring = ""
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)
54 else
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)
56 end
57 end
58 return formstring
59 end)
61 -- nodes which have flower placement rules
62 doc.sub.items.register_factoid("nodes", "groups", function(itemstring, def)
63 local datastring = ""
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."
68 end
69 return ""
70 end)
72 -- flammable
73 doc.sub.items.register_factoid("nodes", "groups", function(itemstring, def)
74 if def.groups.flammable then
75 return "This block is flammable."
76 end
77 return ""
78 end)
80 -- destroys_items
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."
84 end
85 return ""
86 end)
89 -- Comestibles
90 doc.sub.items.register_factoid(nil, "use", function(itemstring, def)
91 local s = ""
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."
97 else
98 s = s .. "\n" .. "You cannot eat this when your hunger bar is full."
99 end
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."
105 else
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."
115 return s
116 end)
118 doc.sub.items.register_factoid(nil, "groups", function(itemstring, def)
119 local s = ""
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)
126 return s
127 end)
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]
133 local desc
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)
143 return ""
144 end)
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."
149 else
150 return ""
152 end)
154 doc.sub.items.register_factoid("nodes", "gravity", function(itemstring, def)
155 local s = ""
156 if minetest.get_item_group(itemstring, "crush_after_fall") == 1 then
157 s = s .. "This block crushes any block it falls into."
159 return s
160 end)
162 doc.sub.items.register_factoid("nodes", "gravity", function(itemstring, def)
163 local s = ""
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."
167 return s
168 end)
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
178 if groups then
179 if groups.dig_immediate == 3 then
180 datastring = datastring .. "This block can be mined by any tool instantly." .. "\n"
181 else
182 local tool_minable = false
184 if groups.pickaxey then
185 for g=1, 6-groups.pickaxey do
186 datastring = datastring .. "• " .. pickaxey[g] .. "\n"
188 tool_minable = true
190 if groups.axey then
191 for g=1, 6-groups.axey do
192 datastring = datastring .. "• " .. axey[g] .. "\n"
194 tool_minable = true
196 if groups.shovely then
197 for g=1, 6-groups.shovely do
198 datastring = datastring .. "• " .. shovely[g] .. "\n"
200 tool_minable = true
202 if groups.shearsy or groups.shearsy_wool then
203 datastring = datastring .. "• Shears" .. "\n"
204 tool_minable = true
206 if groups.swordy or groups.swordy_cobweb then
207 datastring = datastring .. "• Sword" .. "\n"
208 tool_minable = true
210 if groups.handy then
211 datastring = datastring .. "• Hand" .. "\n"
212 tool_minable = true
215 if tool_minable then
216 datastring = "This block can be mined by:\n" .. datastring .. "\n"
220 local hardness = def._mcl_hardness
221 if not hardness then
222 hardness = 0
224 if hardness == -1 then
225 datastring = datastring .. "Hardness: ∞"
226 else
227 datastring = datastring .. string.format("Hardness: %.2f", hardness)
229 local blast = def._mcl_blast_resistance
230 if not blast then
231 blast = 0
233 -- TODO: Blast resistance as number
234 if blast >= 1000 then
235 datastring = datastring .. "\n" .. "This block will not be destroyed by TNT explosions."
237 return datastring
238 end)
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
245 local drops = {}
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]
251 local text = ""
252 if idef.description and idef.description ~= "" then
253 text = idef.description
254 else
255 text = itemname
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, ", "))
263 return ret
265 return ""
266 end)