Rename "tool_multiplier" to "speed" for tools

This commit is contained in:
Elias Åström 2021-03-20 19:25:47 +01:00
parent 1873080046
commit 1621c23308
2 changed files with 48 additions and 49 deletions

View file

@ -6,7 +6,7 @@ block has a hardness and the actual Minecraft digging time is determined by
this:
1) The block's hardness
2) The tool being used (the tool_multiplier and its efficiency level)
2) The tool being used (the tool speed and its efficiency level)
3) Whether the tool is considered as "eligible" for the block
(e.g. only diamond pick eligible for obsidian)
@ -43,13 +43,13 @@ this field is a table which defines which groups the tool can dig and how
efficiently.
_mcl_diggroups = {
handy = { tool_multiplier = 1, level = 1, uses = 0 },
pickaxey = { tool_multiplier = 1, level = 0, uses = 0 },
handy = { speed = 1, level = 1, uses = 0 },
pickaxey = { speed = 1, level = 0, uses = 0 },
}
The "uses" field indicate how many uses (0 for infinite) a tool has when used on
the specified digging group. The "tool_multiplier" field is a multiplier to the
dig speed on that digging group.
the specified digging group. The "speed" field is a multiplier to the dig speed
on that digging group.
The "level" field indicates which levels of the group the tool can harvest. A
level of 0 means that the tool cannot harvest blocks of that node. A level of 1
@ -135,19 +135,18 @@ end
-- Parameters:
-- group - the group which it is digging
-- can_harvest - if the tool can harvest the block
-- tool_multiplier - dig speed multiplier for tool (default 1)
-- speed - dig speed multiplier for tool (default 1)
-- efficiency - efficiency level for the tool if applicable
local function get_digtimes(group, can_harvest, tool_multiplier, efficiency)
tool_multiplier = tool_multiplier or 1
local speed_multiplier = tool_multiplier
local function get_digtimes(group, can_harvest, speed, efficiency)
local speed = speed or 1
if efficiency then
speed_multiplier = speed_multiplier + efficiency * efficiency + 1
speed = speed + efficiency * efficiency + 1
end
local digtimes = {}
for index, hardness in pairs(hardness_values[group]) do
local digtime = (hardness or 0) / speed_multiplier
local digtime = (hardness or 0) / speed
if can_harvest then
digtime = digtime * 1.5
else
@ -178,7 +177,7 @@ end
-- tool.
local function add_groupcaps(toolname, groupcaps, groupcaps_def, efficiency)
for g, capsdef in pairs(groupcaps_def) do
local mult = capsdef.tool_multiplier or 1
local mult = capsdef.speed or 1
local uses = capsdef.uses
local def = mcl_autogroup.registered_diggroups[g]
local max_level = def.levels and #def.levels or 1

View file

@ -48,15 +48,15 @@ minetest.register_tool(":", {
},
groups = hand_groups,
_mcl_diggroups = {
handy = { tool_multiplier = 1, level = 1, uses = 0 },
axey = { tool_multiplier = 1, level = 1, uses = 0 },
shovely = { tool_multiplier = 1, level = 1, uses = 0 },
pickaxey = { tool_multiplier = 1, level = 0, uses = 0 },
swordy = { tool_multiplier = 1, level = 0, uses = 0 },
swordy_cobweb = { tool_multiplier = 1, level = 0, uses = 0 },
shearsy = { tool_multiplier = 1, level = 0, uses = 0 },
shearsy_wool = { tool_multiplier = 1, level = 0, uses = 0 },
shearsy_cobweb = { tool_multiplier = 1, level = 0, uses = 0 },
handy = { speed = 1, level = 1, uses = 0 },
axey = { speed = 1, level = 1, uses = 0 },
shovely = { speed = 1, level = 1, uses = 0 },
pickaxey = { speed = 1, level = 0, uses = 0 },
swordy = { speed = 1, level = 0, uses = 0 },
swordy_cobweb = { speed = 1, level = 0, uses = 0 },
shearsy = { speed = 1, level = 0, uses = 0 },
shearsy_wool = { speed = 1, level = 0, uses = 0 },
shearsy_cobweb = { speed = 1, level = 0, uses = 0 },
}
})
@ -90,7 +90,7 @@ minetest.register_tool("mcl_tools:pick_wood", {
_repair_material = "group:wood",
_mcl_toollike_wield = true,
_mcl_diggroups = {
pickaxey = { tool_multiplier = 2, level = 1, uses = 60 }
pickaxey = { speed = 2, level = 1, uses = 60 }
},
})
minetest.register_tool("mcl_tools:pick_stone", {
@ -110,7 +110,7 @@ minetest.register_tool("mcl_tools:pick_stone", {
_repair_material = "mcl_core:cobble",
_mcl_toollike_wield = true,
_mcl_diggroups = {
pickaxey = { tool_multiplier = 4, level = 3, uses = 132 }
pickaxey = { speed = 4, level = 3, uses = 132 }
},
})
minetest.register_tool("mcl_tools:pick_iron", {
@ -130,7 +130,7 @@ minetest.register_tool("mcl_tools:pick_iron", {
_repair_material = "mcl_core:iron_ingot",
_mcl_toollike_wield = true,
_mcl_diggroups = {
pickaxey = { tool_multiplier = 6, level = 4, uses = 251 }
pickaxey = { speed = 6, level = 4, uses = 251 }
},
})
minetest.register_tool("mcl_tools:pick_gold", {
@ -150,7 +150,7 @@ minetest.register_tool("mcl_tools:pick_gold", {
_repair_material = "mcl_core:gold_ingot",
_mcl_toollike_wield = true,
_mcl_diggroups = {
pickaxey = { tool_multiplier = 12, level = 2, uses = 33 }
pickaxey = { speed = 12, level = 2, uses = 33 }
},
})
minetest.register_tool("mcl_tools:pick_diamond", {
@ -170,7 +170,7 @@ minetest.register_tool("mcl_tools:pick_diamond", {
_repair_material = "mcl_core:diamond",
_mcl_toollike_wield = true,
_mcl_diggroups = {
pickaxey = { tool_multiplier = 8, level = 5, uses = 1562 }
pickaxey = { speed = 8, level = 5, uses = 1562 }
},
})
@ -262,7 +262,7 @@ minetest.register_tool("mcl_tools:shovel_wood", {
_repair_material = "group:wood",
_mcl_toollike_wield = true,
_mcl_diggroups = {
shovely = { tool_multiplier = 2, level = 1, uses = 60 }
shovely = { speed = 2, level = 1, uses = 60 }
},
})
minetest.register_tool("mcl_tools:shovel_stone", {
@ -283,7 +283,7 @@ minetest.register_tool("mcl_tools:shovel_stone", {
_repair_material = "mcl_core:cobble",
_mcl_toollike_wield = true,
_mcl_diggroups = {
shovely = { tool_multiplier = 4, level = 3, uses = 132 }
shovely = { speed = 4, level = 3, uses = 132 }
},
})
minetest.register_tool("mcl_tools:shovel_iron", {
@ -304,7 +304,7 @@ minetest.register_tool("mcl_tools:shovel_iron", {
_repair_material = "mcl_core:iron_ingot",
_mcl_toollike_wield = true,
_mcl_diggroups = {
shovely = { tool_multiplier = 6, level = 4, uses = 251 }
shovely = { speed = 6, level = 4, uses = 251 }
},
})
minetest.register_tool("mcl_tools:shovel_gold", {
@ -325,7 +325,7 @@ minetest.register_tool("mcl_tools:shovel_gold", {
_repair_material = "mcl_core:gold_ingot",
_mcl_toollike_wield = true,
_mcl_diggroups = {
shovely = { tool_multiplier = 12, level = 2, uses = 33 }
shovely = { speed = 12, level = 2, uses = 33 }
},
})
minetest.register_tool("mcl_tools:shovel_diamond", {
@ -346,7 +346,7 @@ minetest.register_tool("mcl_tools:shovel_diamond", {
_repair_material = "mcl_core:diamond",
_mcl_toollike_wield = true,
_mcl_diggroups = {
shovely = { tool_multiplier = 8, level = 5, uses = 1562 }
shovely = { speed = 8, level = 5, uses = 1562 }
},
})
@ -368,7 +368,7 @@ minetest.register_tool("mcl_tools:axe_wood", {
_repair_material = "group:wood",
_mcl_toollike_wield = true,
_mcl_diggroups = {
axey = { tool_multiplier = 2, level = 1, uses = 60 }
axey = { speed = 2, level = 1, uses = 60 }
},
})
minetest.register_tool("mcl_tools:axe_stone", {
@ -387,7 +387,7 @@ minetest.register_tool("mcl_tools:axe_stone", {
_repair_material = "mcl_core:cobble",
_mcl_toollike_wield = true,
_mcl_diggroups = {
axey = { tool_multiplier = 4, level = 3, uses = 132 }
axey = { speed = 4, level = 3, uses = 132 }
},
})
minetest.register_tool("mcl_tools:axe_iron", {
@ -407,7 +407,7 @@ minetest.register_tool("mcl_tools:axe_iron", {
_repair_material = "mcl_core:iron_ingot",
_mcl_toollike_wield = true,
_mcl_diggroups = {
axey = { tool_multiplier = 6, level = 4, uses = 251 }
axey = { speed = 6, level = 4, uses = 251 }
},
})
minetest.register_tool("mcl_tools:axe_gold", {
@ -426,7 +426,7 @@ minetest.register_tool("mcl_tools:axe_gold", {
_repair_material = "mcl_core:gold_ingot",
_mcl_toollike_wield = true,
_mcl_diggroups = {
axey = { tool_multiplier = 12, level = 2, uses = 33 }
axey = { speed = 12, level = 2, uses = 33 }
},
})
minetest.register_tool("mcl_tools:axe_diamond", {
@ -445,7 +445,7 @@ minetest.register_tool("mcl_tools:axe_diamond", {
_repair_material = "mcl_core:diamond",
_mcl_toollike_wield = true,
_mcl_diggroups = {
axey = { tool_multiplier = 8, level = 5, uses = 1562 }
axey = { speed = 8, level = 5, uses = 1562 }
},
})
@ -467,8 +467,8 @@ minetest.register_tool("mcl_tools:sword_wood", {
_repair_material = "group:wood",
_mcl_toollike_wield = true,
_mcl_diggroups = {
swordy = { tool_multiplier = 2, level = 1, uses = 60 },
swordy_cobweb = { tool_multiplier = 2, level = 1, uses = 60 }
swordy = { speed = 2, level = 1, uses = 60 },
swordy_cobweb = { speed = 2, level = 1, uses = 60 }
},
})
minetest.register_tool("mcl_tools:sword_stone", {
@ -487,8 +487,8 @@ minetest.register_tool("mcl_tools:sword_stone", {
_repair_material = "mcl_core:cobble",
_mcl_toollike_wield = true,
_mcl_diggroups = {
swordy = { tool_multiplier = 4, level = 3, uses = 132 },
swordy_cobweb = { tool_multiplier = 4, level = 3, uses = 132 }
swordy = { speed = 4, level = 3, uses = 132 },
swordy_cobweb = { speed = 4, level = 3, uses = 132 }
},
})
minetest.register_tool("mcl_tools:sword_iron", {
@ -507,8 +507,8 @@ minetest.register_tool("mcl_tools:sword_iron", {
_repair_material = "mcl_core:iron_ingot",
_mcl_toollike_wield = true,
_mcl_diggroups = {
swordy = { tool_multiplier = 6, level = 4, uses = 251 },
swordy_cobweb = { tool_multiplier = 6, level = 4, uses = 251 }
swordy = { speed = 6, level = 4, uses = 251 },
swordy_cobweb = { speed = 6, level = 4, uses = 251 }
},
})
minetest.register_tool("mcl_tools:sword_gold", {
@ -527,8 +527,8 @@ minetest.register_tool("mcl_tools:sword_gold", {
_repair_material = "mcl_core:gold_ingot",
_mcl_toollike_wield = true,
_mcl_diggroups = {
swordy = { tool_multiplier = 12, level = 2, uses = 33 },
swordy_cobweb = { tool_multiplier = 12, level = 2, uses = 33 }
swordy = { speed = 12, level = 2, uses = 33 },
swordy_cobweb = { speed = 12, level = 2, uses = 33 }
},
})
minetest.register_tool("mcl_tools:sword_diamond", {
@ -547,8 +547,8 @@ minetest.register_tool("mcl_tools:sword_diamond", {
_repair_material = "mcl_core:diamond",
_mcl_toollike_wield = true,
_mcl_diggroups = {
swordy = { tool_multiplier = 8, level = 5, uses = 1562 },
swordy_cobweb = { tool_multiplier = 8, level = 5, uses = 1562 }
swordy = { speed = 8, level = 5, uses = 1562 },
swordy_cobweb = { speed = 8, level = 5, uses = 1562 }
},
})
@ -569,9 +569,9 @@ minetest.register_tool("mcl_tools:shears", {
sound = { breaks = "default_tool_breaks" },
_mcl_toollike_wield = true,
_mcl_diggroups = {
shearsy = { tool_multiplier = 1.5, level = 1, uses = 238 },
shearsy_wool = { tool_multiplier = 5, level = 1, uses = 238 },
shearsy_cobweb = { tool_multiplier = 15, level = 1, uses = 238 }
shearsy = { speed = 1.5, level = 1, uses = 238 },
shearsy_wool = { speed = 5, level = 1, uses = 238 },
shearsy_cobweb = { speed = 15, level = 1, uses = 238 }
},
})