1
0
Fork 0
MineClone2/mods/HELP/mcl_doc/init.lua

227 lines
7.3 KiB
Lua
Raw Normal View History

2017-03-18 03:27:36 +01:00
-- Disable built-in factoids; it is planned to add custom ones as replacements
doc.sub.items.disable_core_factoid("node_mining")
doc.sub.items.disable_core_factoid("tool_capabilities")
2017-03-18 03:27:36 +01:00
-- Help button callback
minetest.register_on_player_receive_fields(function(player, formname, fields)
if fields.__mcl_doc then
doc.show_doc(player:get_player_name())
end
end)
-- doc_items factoids
-- dig_by_water
doc.sub.items.register_factoid("nodes", "drop_destroy", function(itemstring, def)
if def.groups.dig_by_water then
return "Water can flow into this block and cause it to drop as an item."
end
return ""
end)
-- usable by hoes
doc.sub.items.register_factoid("nodes", "groups", function(itemstring, def)
if def.groups.cultivatable == 2 then
return "This block can be turned into dirt with a hoe."
elseif def.groups.cultivatable == 2 then
return "This block can be turned into farmland with a hoe."
end
return ""
end)
-- soil
doc.sub.items.register_factoid("nodes", "groups", function(itemstring, def)
local datastring = ""
if def.groups.soil_sapling == 2 then
datastring = datastring .. "This block acts as a soil for all saplings." .. "\n"
elseif def.groups.soil_sapling == 1 then
datastring = datastring .. "This block acts as a soil for some saplings." .. "\n"
end
if def.groups.soil_sugarcane then
datastring = datastring .. "Sugar canes will grow on this block." .. "\n"
end
if def.groups.soil_nether_wart then
datastring = datastring .. "Nether wart will grow on this block." .. "\n"
end
return datastring
end)
doc.sub.items.register_factoid("nodes", "groups", function(itemstring, def)
local formstring = ""
if def.groups.leafdecay ~= nil then
if def.drop ~= "" and def.drop ~= nil and def.drop ~= itemstring then
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)
else
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)
end
end
return formstring
end)
2017-06-11 23:20:50 +02:00
-- nodes which have flower placement rules
2017-06-09 21:26:26 +02:00
doc.sub.items.register_factoid("nodes", "groups", function(itemstring, def)
local datastring = ""
2017-06-11 23:20:50 +02:00
if def.groups.place_flowerlike == 1 then
return "This plant can only grow on dirt, grass blocks and podzol. To survive, it needs to have an unobstructed view to the sky above or be exposed to a light level of 8 or higher."
2017-06-09 21:26:26 +02:00
end
return ""
end)
-- flammable
doc.sub.items.register_factoid("nodes", "groups", function(itemstring, def)
if def.groups.flammable then
return "This block is flammable."
end
return ""
end)
-- destroys_items
doc.sub.items.register_factoid("nodes", "groups", function(itemstring, def)
if def.groups.destroys_items then
return "This block destroys any item it touches."
end
return ""
end)
-- Comestibles
doc.sub.items.register_factoid(nil, "use", function(itemstring, def)
2017-05-23 02:55:48 +02:00
local s = ""
if def.groups.eatable and not def._doc_items_usagehelp then
if def.groups.food == 2 then
2017-05-23 02:55:48 +02:00
s = s .. "To eat it, wield it, then rightclick."
if def.groups.can_eat_when_full == 1 then
s = s .. "\n" .. "You can eat this even when your hunger bar is full."
else
s = s .. "\n" .. "You cannot eat this when your hunger bar is full."
end
elseif def.groups.food == 3 then
2017-05-23 02:55:48 +02:00
s = s .. "To drink it, wield it, then rightclick."
if def.groups.can_eat_when_full ~= 1 then
s = s .. "\n" .. "You cannot drink this when your hunger bar is full."
end
else
2017-05-23 02:55:48 +02:00
s = s .. "To consume it, wield it, then rightclick."
if def.groups.can_eat_when_full ~= 1 then
s = s .. "\n" .. "You cannot consume this when your hunger bar is full."
end
end
if def.groups.no_eat_delay ~= 1 then
s = s .. "\n" .. "You have to wait for about 2 seconds before you can eat or drink again."
end
end
2017-05-23 02:55:48 +02:00
return s
end)
2017-03-18 19:38:40 +01:00
2017-05-21 03:12:17 +02:00
doc.sub.items.register_factoid(nil, "groups", function(itemstring, def)
local s = ""
if def.groups.eatable and def.groups.eatable > 0 then
s = s .. string.format("Hunger points restored: %d", def.groups.eatable)
end
if def._mcl_saturation and def._mcl_saturation > 0 then
s = s .. "\n" .. string.format("Saturation points restored: %.1f", def._mcl_saturation)
end
return s
end)
2017-03-22 18:48:27 +01:00
-- Mining, hardness and all that
2017-03-18 19:38:40 +01:00
doc.sub.items.register_factoid("nodes", "mining", function(itemstring, def)
2017-03-22 18:48:27 +01:00
local pickaxey = { "Diamond Pickaxe", "Iron Pickaxe", "Stone Pickaxe", "Golden Pickaxe", "Wooden Pickaxe" }
local axey = { "Diamond Axe", "Iron Axe", "Stone Axe", "Golden Axe", "Wooden Axe" }
local shovely = { "Diamond Shovel", "Iron Shovel", "Stone Shovel", "Golden Shovel", "Wooden Shovel" }
local datastring = ""
local groups = def.groups
if groups then
if groups.dig_immediate == 3 then
datastring = datastring .. "This block can be mined by any tool instantly." .. "\n"
else
local tool_minable = false
if groups.pickaxey then
for g=1, 6-groups.pickaxey do
datastring = datastring .. "" .. pickaxey[g] .. "\n"
end
tool_minable = true
end
if groups.axey then
for g=1, 6-groups.axey do
datastring = datastring .. "" .. axey[g] .. "\n"
end
tool_minable = true
end
if groups.shovely then
for g=1, 6-groups.shovely do
datastring = datastring .. "" .. shovely[g] .. "\n"
end
tool_minable = true
end
2017-08-03 03:50:02 +02:00
if groups.shearsy or groups.shearsy_wool then
2017-03-22 18:48:27 +01:00
datastring = datastring .. "• Shears" .. "\n"
tool_minable = true
end
2017-08-03 03:50:02 +02:00
if groups.swordy or groups.swordy_cobweb then
2017-03-22 18:48:27 +01:00
datastring = datastring .. "• Sword" .. "\n"
tool_minable = true
end
if groups.handy then
datastring = datastring .. "• Hand" .. "\n"
tool_minable = true
end
if tool_minable then
datastring = "This block can be mined by:\n" .. datastring .. "\n"
end
end
end
2017-03-18 19:38:40 +01:00
local hardness = def._mcl_hardness
if not hardness then
hardness = 0
end
2017-03-20 21:41:27 +01:00
if hardness == -1 then
2017-03-22 18:48:27 +01:00
datastring = datastring .. "Hardness: ∞"
2017-03-20 21:41:27 +01:00
else
2017-03-22 18:48:27 +01:00
datastring = datastring .. string.format("Hardness: %.2f", hardness)
2017-03-20 21:41:27 +01:00
end
2017-06-05 22:20:27 +02:00
local blast = def._mcl_blast_resistance
if not blast then
blast = 0
end
if blast >= 1000 then
datastring = datastring .. "\n" .. "This block will not be destroyed by TNT explosions."
end
2017-03-22 18:48:27 +01:00
return datastring
2017-03-18 19:38:40 +01:00
end)
2017-08-03 03:05:41 +02:00
-- Special drops when mined by shears
doc.sub.items.register_factoid("nodes", "drops", function(itemstring, def)
if def._mcl_shears_drop == true then
return "This block drops itself when mined by shears."
elseif type(def._mcl_shears_drop) == "table" then
local drops = {}
for d=1, #def._mcl_shears_drop do
local item = ItemStack(def._mcl_shears_drop[d])
local itemname = item:get_name()
local itemcount = item:get_count()
local idef = minetest.registered_items[itemname]
local text = ""
if idef.description and idef.description ~= "" then
text = idef.description
2017-08-03 03:05:41 +02:00
else
text = itemname
2017-08-03 03:05:41 +02:00
end
if itemcount > 1 then
text = string.format("%d×%s", itemcount, text)
end
table.insert(drops, text)
2017-08-03 03:05:41 +02:00
end
local ret = string.format("This blocks drops the following when mined by shears: %s", table.concat(drops, ", "))
return ret
end
return ""
end)
2017-03-18 19:38:40 +01:00
-- TODO: Blast resistance (omitted for now because explosions ignore hardness)