mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-26 20:41:11 +01:00
142 lines
4.1 KiB
Lua
142 lines
4.1 KiB
Lua
-- 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")
|
|
|
|
-- 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)
|
|
|
|
-- 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)
|
|
if def.groups.eatable and not def._doc_items_usagehelp then
|
|
if def.groups.food == 2 then
|
|
return "To eat it, wield it, then rightclick."
|
|
elseif def.groups.food == 3 then
|
|
return "To drink it, wield it, then rightclick."
|
|
else
|
|
return "To consume it, wield it, then rightclick."
|
|
end
|
|
end
|
|
return ""
|
|
end)
|
|
|
|
-- Mining, hardness and all that
|
|
doc.sub.items.register_factoid("nodes", "mining", function(itemstring, def)
|
|
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
|
|
if groups.shearsy then
|
|
datastring = datastring .. "• Shears" .. "\n"
|
|
tool_minable = true
|
|
end
|
|
if groups.swordy then
|
|
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
|
|
local hardness = def._mcl_hardness
|
|
if not hardness then
|
|
hardness = 0
|
|
end
|
|
if hardness == -1 then
|
|
datastring = datastring .. "Hardness: ∞"
|
|
else
|
|
datastring = datastring .. string.format("Hardness: %.2f", hardness)
|
|
end
|
|
return datastring
|
|
end)
|
|
|
|
-- TODO: Blast resistance (omitted for now because explosions ignore hardness)
|