mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-25 20:11:06 +01:00
Add tool stats in help
This commit is contained in:
parent
bcffcdf003
commit
641921f4c7
4 changed files with 177 additions and 25 deletions
|
@ -267,4 +267,114 @@ doc.sub.items.register_factoid("nodes", "drops", function(itemstring, def)
|
|||
return ""
|
||||
end)
|
||||
|
||||
-- Digging capabilities of tool
|
||||
doc.sub.items.register_factoid("tools", "misc", function(itemstring, def)
|
||||
if not def.tool_capabilities then
|
||||
return ""
|
||||
end
|
||||
local groupcaps = def.tool_capabilities.groupcaps
|
||||
if not groupcaps then
|
||||
return ""
|
||||
end
|
||||
local formstring = ""
|
||||
local capstr = ""
|
||||
local caplines = 0
|
||||
for k,v in pairs(groupcaps) do
|
||||
local speedstr = ""
|
||||
local miningusesstr = ""
|
||||
-- Mining capabilities
|
||||
caplines = caplines + 1
|
||||
local maxlevel = v.maxlevel
|
||||
if not maxlevel then
|
||||
-- Default from tool.h
|
||||
maxlevel = 1
|
||||
end
|
||||
|
||||
-- Digging speed
|
||||
local speed_class = def.groups and def.groups.dig_speed_class
|
||||
if speed_class == 1 then
|
||||
speedstr = S("Painfully slow")
|
||||
elseif speed_class == 2 then
|
||||
speedstr = S("Very slow")
|
||||
elseif speed_class == 3 then
|
||||
speedstr = S("Slow")
|
||||
elseif speed_class == 4 then
|
||||
speedstr = S("Fast")
|
||||
elseif speed_class == 5 then
|
||||
speedstr = S("Very fast")
|
||||
elseif speed_class == 6 then
|
||||
speedstr = S("Extremely fast")
|
||||
elseif speed_class == 7 then
|
||||
speedstr = S("Instantaneous")
|
||||
end
|
||||
|
||||
-- Number of mining uses
|
||||
local base_uses = v.uses
|
||||
if not base_uses then
|
||||
-- Default from tool.h
|
||||
base_uses = 20
|
||||
end
|
||||
if def._doc_items_durability == nil and base_uses > 0 then
|
||||
local real_uses = base_uses * math.pow(3, maxlevel)
|
||||
if real_uses < 65535 then
|
||||
miningusesstr = S("@1 uses", real_uses)
|
||||
else
|
||||
miningusesstr = S("Unlimited uses")
|
||||
end
|
||||
end
|
||||
|
||||
if speedstr ~= "" then
|
||||
capstr = capstr .. S("Mining speed: @1", speedstr) .. "\n"
|
||||
end
|
||||
if miningusesstr ~= "" then
|
||||
capstr = capstr .. S("Mining durability: @1", miningusesstr) .. "\n"
|
||||
end
|
||||
|
||||
-- Only show one group at max
|
||||
break
|
||||
end
|
||||
if caplines > 0 then
|
||||
formstring = formstring .. S("This tool is capable of mining.") .. "\n"
|
||||
-- Capabilities
|
||||
formstring = formstring .. capstr
|
||||
-- Max. drop level
|
||||
local mdl = def.tool_capabilities.max_drop_level
|
||||
if not def.tool_capabilities.max_drop_level then
|
||||
mdl = 0
|
||||
end
|
||||
formstring = formstring .. S("Block breaking strength: @1", mdl) .. "\n"
|
||||
end
|
||||
if caplines > 0 then
|
||||
formstring = formstring .. "\n\n"
|
||||
end
|
||||
return formstring
|
||||
end)
|
||||
|
||||
-- Melee damage
|
||||
doc.sub.items.register_factoid("tools", "misc", function(itemstring, def)
|
||||
local tool_capabilities = def.tool_capabilities
|
||||
if not tool_capabilities then
|
||||
return ""
|
||||
end
|
||||
|
||||
local formstring = ""
|
||||
-- Weapon data
|
||||
local damage_groups = tool_capabilities.damage_groups
|
||||
if damage_groups ~= nil and damage_groups.fleshy ~= nil then
|
||||
formstring = formstring .. S("This is a melee weapon which deals damage by punching.") .. "\n"
|
||||
|
||||
-- Damage groups
|
||||
local dmg = damage_groups.fleshy
|
||||
formstring = formstring .. S("Maximum damage: @1 HP", dmg) .. "\n"
|
||||
|
||||
-- Full punch interval
|
||||
local punch = 1.0
|
||||
if tool_capabilities.full_punch_interval ~= nil then
|
||||
punch = tool_capabilities.full_punch_interval
|
||||
end
|
||||
formstring = formstring .. S("Full punch interval: @1 s", string.format("%.1f", punch))
|
||||
formstring = formstring .. "\n"
|
||||
end
|
||||
return formstring
|
||||
end)
|
||||
|
||||
|
|
|
@ -55,3 +55,19 @@ This blocks drops the following when mined by shears: @1=Dieser Block wird folge
|
|||
• Shears=• Schere
|
||||
• Sword=• Schwert
|
||||
• Hand=• Hand
|
||||
This is a melee weapon which deals damage by punching.=Dies ist eine Nahkampfwaffe, die Schaden durch Schläge verursacht.
|
||||
Maximum damage: @1 HP=Maximalschaden: @1 HP
|
||||
Full punch interval: @1 s=Ausholintervall: @1 s
|
||||
This tool is capable of mining.=Dieses Werkzeug kann Blöcke abbauen.
|
||||
Mining speed: @1=Grabegeschwindigkeit: @1
|
||||
Painfully slow=Furchtbar langsam
|
||||
Very slow=Sehr langsam
|
||||
Slow=Langsam
|
||||
Fast=Schnell
|
||||
Very fast=Sehr schnell
|
||||
Extremely fast=Extrem schnell
|
||||
Instantaneous=Unmittelbar
|
||||
@1 uses=@1 Verwendungen
|
||||
Unlimited uses=Unbegrenzte Verwendungen
|
||||
Block breaking strength: @1=Blockbruchstärke: @1
|
||||
Mining durability: @1=Grabehaltbarkeit: @1
|
||||
|
|
|
@ -55,3 +55,19 @@ This blocks drops the following when mined by shears: @1=
|
|||
• Shears=
|
||||
• Sword=
|
||||
• Hand=
|
||||
This is a melee weapon which deals damage by punching.=
|
||||
Maximum damage: @1 HP=
|
||||
Full punch interval: @1 s=
|
||||
This tool is capable of mining.=
|
||||
Mining speed: @1=
|
||||
Painfully slow=
|
||||
Very slow=
|
||||
Slow=
|
||||
Fast=
|
||||
Very fast=
|
||||
Extremely fast=
|
||||
Instantaneous=
|
||||
@1 uses=
|
||||
Unlimited uses=
|
||||
Block breaking strength: @1=
|
||||
Mining durability: @1=
|
||||
|
|
|
@ -13,12 +13,19 @@ local S = minetest.get_translator("mcl_tools")
|
|||
- 3: Stone
|
||||
- 4: Iron
|
||||
- 5: Diamond
|
||||
|
||||
dig_speed_class group:
|
||||
- 1: Painfully slow
|
||||
- 2: Very slow
|
||||
- 3: Slow
|
||||
- 4: Fast
|
||||
- 5: Very fast
|
||||
- 6: Extremely fast
|
||||
- 7: Instantaneous
|
||||
]]
|
||||
|
||||
-- TODO: Add legacy support for Minetest Game groups like crumbly, snappy, cracky, etc. for all tools
|
||||
|
||||
-- The hand
|
||||
local groupcaps, hand_range
|
||||
local groupcaps, hand_range, hand_groups
|
||||
if minetest.settings:get_bool("creative_mode") then
|
||||
-- Instant breaking in creative mode
|
||||
groupcaps = {
|
||||
|
@ -29,11 +36,13 @@ if minetest.settings:get_bool("creative_mode") then
|
|||
groupcaps[k] = { times = v, uses = 0 }
|
||||
end
|
||||
hand_range = 10
|
||||
hand_groups = { dig_speed_class = 7 }
|
||||
else
|
||||
groupcaps = {
|
||||
handy_dig = {times=mcl_autogroup.digtimes.handy_dig, uses=0},
|
||||
}
|
||||
hand_range = 4
|
||||
hand_groups = { dig_speed_class = 1 }
|
||||
end
|
||||
minetest.register_item(":", {
|
||||
type = "none",
|
||||
|
@ -50,7 +59,8 @@ minetest.register_item(":", {
|
|||
max_drop_level = 0,
|
||||
groupcaps = groupcaps,
|
||||
damage_groups = {fleshy=1},
|
||||
}
|
||||
},
|
||||
groups = hand_groups,
|
||||
})
|
||||
|
||||
-- Help texts
|
||||
|
@ -68,7 +78,7 @@ minetest.register_tool("mcl_tools:pick_wood", {
|
|||
_doc_items_longdesc = pickaxe_longdesc,
|
||||
_doc_items_hidden = false,
|
||||
inventory_image = "default_tool_woodpick.png",
|
||||
groups = { tool=1, pickaxe=1 },
|
||||
groups = { tool=1, pickaxe=1, dig_speed_class=2, },
|
||||
tool_capabilities = {
|
||||
-- 1/1.2
|
||||
full_punch_interval = 0.83333333,
|
||||
|
@ -85,7 +95,7 @@ minetest.register_tool("mcl_tools:pick_stone", {
|
|||
description = S("Stone Pickaxe"),
|
||||
_doc_items_longdesc = pickaxe_longdesc,
|
||||
inventory_image = "default_tool_stonepick.png",
|
||||
groups = { tool=1, pickaxe=1 },
|
||||
groups = { tool=1, pickaxe=1, dig_speed_class=3, },
|
||||
tool_capabilities = {
|
||||
-- 1/1.2
|
||||
full_punch_interval = 0.83333333,
|
||||
|
@ -102,7 +112,7 @@ minetest.register_tool("mcl_tools:pick_iron", {
|
|||
description = S("Iron Pickaxe"),
|
||||
_doc_items_longdesc = pickaxe_longdesc,
|
||||
inventory_image = "default_tool_steelpick.png",
|
||||
groups = { tool=1, pickaxe=1 },
|
||||
groups = { tool=1, pickaxe=1, dig_speed_class=4, },
|
||||
tool_capabilities = {
|
||||
-- 1/1.2
|
||||
full_punch_interval = 0.83333333,
|
||||
|
@ -119,7 +129,7 @@ minetest.register_tool("mcl_tools:pick_gold", {
|
|||
description = S("Golden Pickaxe"),
|
||||
_doc_items_longdesc = pickaxe_longdesc,
|
||||
inventory_image = "default_tool_goldpick.png",
|
||||
groups = { tool=1, pickaxe=1 },
|
||||
groups = { tool=1, pickaxe=1, dig_speed_class=6, },
|
||||
tool_capabilities = {
|
||||
-- 1/1.2
|
||||
full_punch_interval = 0.83333333,
|
||||
|
@ -136,7 +146,7 @@ minetest.register_tool("mcl_tools:pick_diamond", {
|
|||
description = S("Diamond Pickaxe"),
|
||||
_doc_items_longdesc = pickaxe_longdesc,
|
||||
inventory_image = "default_tool_diamondpick.png",
|
||||
groups = { tool=1, pickaxe=1 },
|
||||
groups = { tool=1, pickaxe=1, dig_speed_class=5, },
|
||||
tool_capabilities = {
|
||||
-- 1/1.2
|
||||
full_punch_interval = 0.83333333,
|
||||
|
@ -254,7 +264,7 @@ minetest.register_tool("mcl_tools:shovel_wood", {
|
|||
_doc_items_hidden = false,
|
||||
inventory_image = "default_tool_woodshovel.png",
|
||||
wield_image = "default_tool_woodshovel.png^[transformR90",
|
||||
groups = { tool=1, shovel=1 },
|
||||
groups = { tool=1, shovel=1, dig_speed_class=2, },
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 1,
|
||||
max_drop_level=1,
|
||||
|
@ -273,7 +283,7 @@ minetest.register_tool("mcl_tools:shovel_stone", {
|
|||
_doc_items_usagehelp = shovel_use,
|
||||
inventory_image = "default_tool_stoneshovel.png",
|
||||
wield_image = "default_tool_stoneshovel.png^[transformR90",
|
||||
groups = { tool=1, shovel=1 },
|
||||
groups = { tool=1, shovel=1, dig_speed_class=3, },
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 1,
|
||||
max_drop_level=3,
|
||||
|
@ -292,7 +302,7 @@ minetest.register_tool("mcl_tools:shovel_iron", {
|
|||
_doc_items_usagehelp = shovel_use,
|
||||
inventory_image = "default_tool_steelshovel.png",
|
||||
wield_image = "default_tool_steelshovel.png^[transformR90",
|
||||
groups = { tool=1, shovel=1 },
|
||||
groups = { tool=1, shovel=1, dig_speed_class=4, },
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 1,
|
||||
max_drop_level=4,
|
||||
|
@ -311,7 +321,7 @@ minetest.register_tool("mcl_tools:shovel_gold", {
|
|||
_doc_items_usagehelp = shovel_use,
|
||||
inventory_image = "default_tool_goldshovel.png",
|
||||
wield_image = "default_tool_goldshovel.png^[transformR90",
|
||||
groups = { tool=1, shovel=1 },
|
||||
groups = { tool=1, shovel=1, dig_speed_class=6, },
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 1,
|
||||
max_drop_level=2,
|
||||
|
@ -330,7 +340,7 @@ minetest.register_tool("mcl_tools:shovel_diamond", {
|
|||
_doc_items_usagehelp = shovel_use,
|
||||
inventory_image = "default_tool_diamondshovel.png",
|
||||
wield_image = "default_tool_diamondshovel.png^[transformR90",
|
||||
groups = { tool=1, shovel=1 },
|
||||
groups = { tool=1, shovel=1, dig_speed_class=5, },
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 1,
|
||||
max_drop_level=5,
|
||||
|
@ -350,7 +360,7 @@ minetest.register_tool("mcl_tools:axe_wood", {
|
|||
_doc_items_longdesc = axe_longdesc,
|
||||
_doc_items_hidden = false,
|
||||
inventory_image = "default_tool_woodaxe.png",
|
||||
groups = { tool=1, axe=1 },
|
||||
groups = { tool=1, axe=1, dig_speed_class=2, },
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 1.25,
|
||||
max_drop_level=1,
|
||||
|
@ -366,7 +376,7 @@ minetest.register_tool("mcl_tools:axe_stone", {
|
|||
description = S("Stone Axe"),
|
||||
_doc_items_longdesc = axe_longdesc,
|
||||
inventory_image = "default_tool_stoneaxe.png",
|
||||
groups = { tool=1, axe=1 },
|
||||
groups = { tool=1, axe=1, dig_speed_class=3, },
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 1.25,
|
||||
max_drop_level=3,
|
||||
|
@ -382,7 +392,7 @@ minetest.register_tool("mcl_tools:axe_iron", {
|
|||
description = S("Iron Axe"),
|
||||
_doc_items_longdesc = axe_longdesc,
|
||||
inventory_image = "default_tool_steelaxe.png",
|
||||
groups = { tool=1, axe=1 },
|
||||
groups = { tool=1, axe=1, dig_speed_class=4, },
|
||||
tool_capabilities = {
|
||||
-- 1/0.9
|
||||
full_punch_interval = 1.11111111,
|
||||
|
@ -399,7 +409,7 @@ minetest.register_tool("mcl_tools:axe_gold", {
|
|||
description = S("Golden Axe"),
|
||||
_doc_items_longdesc = axe_longdesc,
|
||||
inventory_image = "default_tool_goldaxe.png",
|
||||
groups = { tool=1, axe=1 },
|
||||
groups = { tool=1, axe=1, dig_speed_class=6, },
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 1.0,
|
||||
max_drop_level=2,
|
||||
|
@ -415,7 +425,7 @@ minetest.register_tool("mcl_tools:axe_diamond", {
|
|||
description = S("Diamond Axe"),
|
||||
_doc_items_longdesc = axe_longdesc,
|
||||
inventory_image = "default_tool_diamondaxe.png",
|
||||
groups = { tool=1, axe=1 },
|
||||
groups = { tool=1, axe=1, dig_speed_class=5, },
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 1.0,
|
||||
max_drop_level=5,
|
||||
|
@ -434,7 +444,7 @@ minetest.register_tool("mcl_tools:sword_wood", {
|
|||
_doc_items_longdesc = sword_longdesc,
|
||||
_doc_items_hidden = false,
|
||||
inventory_image = "default_tool_woodsword.png",
|
||||
groups = { weapon=1 },
|
||||
groups = { weapon=1, sword=1, dig_speed_class=2, },
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 0.625,
|
||||
max_drop_level=1,
|
||||
|
@ -451,7 +461,7 @@ minetest.register_tool("mcl_tools:sword_stone", {
|
|||
description = S("Stone Sword"),
|
||||
_doc_items_longdesc = sword_longdesc,
|
||||
inventory_image = "default_tool_stonesword.png",
|
||||
groups = { weapon=1 },
|
||||
groups = { weapon=1, sword=1, dig_speed_class=3, },
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 0.625,
|
||||
max_drop_level=3,
|
||||
|
@ -468,7 +478,7 @@ minetest.register_tool("mcl_tools:sword_iron", {
|
|||
description = S("Iron Sword"),
|
||||
_doc_items_longdesc = sword_longdesc,
|
||||
inventory_image = "default_tool_steelsword.png",
|
||||
groups = { weapon=1 },
|
||||
groups = { weapon=1, sword=1, dig_speed_class=4, },
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 0.625,
|
||||
max_drop_level=4,
|
||||
|
@ -485,7 +495,7 @@ minetest.register_tool("mcl_tools:sword_gold", {
|
|||
description = S("Golden Sword"),
|
||||
_doc_items_longdesc = sword_longdesc,
|
||||
inventory_image = "default_tool_goldsword.png",
|
||||
groups = { weapon=1 },
|
||||
groups = { weapon=1, sword=1, dig_speed_class=6, },
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 0.625,
|
||||
max_drop_level=2,
|
||||
|
@ -502,7 +512,7 @@ minetest.register_tool("mcl_tools:sword_diamond", {
|
|||
description = S("Diamond Sword"),
|
||||
_doc_items_longdesc = sword_longdesc,
|
||||
inventory_image = "default_tool_diamondsword.png",
|
||||
groups = { weapon=1 },
|
||||
groups = { weapon=1, sword=1, dig_speed_class=5, },
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 0.625,
|
||||
max_drop_level=5,
|
||||
|
@ -524,7 +534,7 @@ minetest.register_tool("mcl_tools:shears", {
|
|||
inventory_image = "default_tool_shears.png",
|
||||
wield_image = "default_tool_shears.png",
|
||||
stack_max = 1,
|
||||
groups = { tool=1, shears=1 },
|
||||
groups = { tool=1, shears=1, dig_speed_class=4, },
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 0.5,
|
||||
max_drop_level=1,
|
||||
|
|
Loading…
Reference in a new issue