Rename _mcl_autogroup_groupcaps to _mcl_diggroups

Elias Åström 2021-03-16 20:36:38 +01:00
parent 7b93f68ed8
commit cff0130506
4 changed files with 38 additions and 40 deletions

4
API.md

@ -18,8 +18,8 @@ Items can have these fields:
See `mcl_banners` for an example.
Tools can have these fields:
* `_mcl_autogroup_groupcaps`: Specifies the digging groups that a tool can dig
and how efficiently. See `_mcl_autogroup` for more information.
* `_mcl_diggroups`: Specifies the digging groups that a tool can dig and how
efficiently. See `_mcl_autogroup` for more information.
All nodes can have these fields:

@ -38,11 +38,11 @@ the group indicates which digging level the node requires.
pickaxe of level 4 be mined.
For tools to be able to dig nodes of digging groups they need to use the have
the custom field "_mcl_autogroup_groupcaps" function to get the groupcaps. The
value of this field is a table which defines which groups the tool can dig and
how efficiently.
the custom field "_mcl_diggroups" function to get the groupcaps. The value of
this field is a table which defines which groups the tool can dig and how
efficiently.
_mcl_autogroup_groupcaps = {
_mcl_diggroups = {
handy = { tool_multiplier = 1, level = 1, uses = 0 },
pickaxey = { tool_multiplier = 1, level = 0, uses = 0 },
}
@ -54,8 +54,7 @@ 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
or above means that the tool can harvest nodes with that level or below. See
"mcl_tools/init.lua" for examples on how "_mcl_autogroup_groupcaps" is used in
practice.
"mcl_tools/init.lua" for examples on how "_mcl_diggroups" is used in practice.
Information about the mod
=========================
@ -175,8 +174,8 @@ local function get_groupcap(group, can_harvest, multiplier, efficiency, uses)
}
end
-- Add the groupcaps from a field in "_mcl_autogroup_groupcaps" to the groupcaps
-- of a tool.
-- Add the groupcaps from a field in "_mcl_diggroups" to the groupcaps of a
-- 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
@ -211,7 +210,7 @@ function mcl_autogroup.can_harvest(nodename, toolname)
-- Check if it can be dug by tool
local tdef = minetest.registered_tools[toolname]
if tdef then
for g, gdef in pairs(tdef._mcl_autogroup_groupcaps) do
for g, gdef in pairs(tdef._mcl_diggroups) do
if ndef.groups[g] then
if ndef.groups[g] <= gdef.level then
return true
@ -223,7 +222,7 @@ function mcl_autogroup.can_harvest(nodename, toolname)
-- Check if it can be dug by hand
local tdef = minetest.registered_tools[""]
if tdef then
for g, gdef in pairs(tdef._mcl_autogroup_groupcaps) do
for g, gdef in pairs(tdef._mcl_diggroups) do
if ndef.groups[g] then
if ndef.groups[g] <= gdef.level then
return true
@ -259,7 +258,7 @@ end
function mcl_autogroup.get_groupcaps(toolname, efficiency)
local tdef = minetest.registered_tools[toolname]
local groupcaps = table.copy(tdef.tool_capabilities.groupcaps or {})
add_groupcaps(toolname, groupcaps, tdef._mcl_autogroup_groupcaps, efficiency)
add_groupcaps(toolname, groupcaps, tdef._mcl_diggroups, efficiency)
return groupcaps
end
@ -275,7 +274,7 @@ end
-- loading order.
function mcl_autogroup.get_wear(toolname, diggroup)
local tdef = minetest.registered_tools[toolname]
local uses = tdef._mcl_autogroup_groupcaps[diggroup].uses
local uses = tdef._mcl_diggroups[diggroup].uses
return math.ceil(65535 / uses)
end
@ -321,9 +320,8 @@ local overwrite = function()
for tname, tdef in pairs(minetest.registered_tools) do
-- Assign groupcaps for digging the registered digging groups
-- depending on the _mcl_autogroup_groupcaps in the tool
-- definition
if tdef._mcl_autogroup_groupcaps then
-- depending on the _mcl_diggroups in the tool definition
if tdef._mcl_diggroups then
local toolcaps = table.copy(tdef.tool_capabilities) or {}
toolcaps.groupcaps = mcl_autogroup.get_groupcaps(tname)

@ -236,7 +236,7 @@ function minetest.handle_node_drops(pos, drops, digger)
end
end
local diggroups = tooldef and tooldef._mcl_autogroup_groupcaps
local diggroups = tooldef and tooldef._mcl_diggroups
local shearsy_level = diggroups and diggroups.shearsy and diggroups.shearsy.level
--[[ Special node drops when dug by shears by reading _mcl_shears_drop or with a silk touch tool reading _mcl_silk_touch_drop

@ -68,7 +68,7 @@ minetest.register_tool(":", {
damage_groups = {fleshy=1},
},
groups = hand_groups,
_mcl_autogroup_groupcaps = hand_autogroup_groupcaps,
_mcl_diggroups = hand_autogroup_groupcaps,
})
-- Help texts
@ -100,7 +100,7 @@ minetest.register_tool("mcl_tools:pick_wood", {
sound = { breaks = "default_tool_breaks" },
_repair_material = "group:wood",
_mcl_toollike_wield = true,
_mcl_autogroup_groupcaps = {
_mcl_diggroups = {
pickaxey = { tool_multiplier = 2, level = 1, uses = 60 }
},
})
@ -120,7 +120,7 @@ minetest.register_tool("mcl_tools:pick_stone", {
sound = { breaks = "default_tool_breaks" },
_repair_material = "mcl_core:cobble",
_mcl_toollike_wield = true,
_mcl_autogroup_groupcaps = {
_mcl_diggroups = {
pickaxey = { tool_multiplier = 4, level = 3, uses = 132 }
},
})
@ -140,7 +140,7 @@ minetest.register_tool("mcl_tools:pick_iron", {
sound = { breaks = "default_tool_breaks" },
_repair_material = "mcl_core:iron_ingot",
_mcl_toollike_wield = true,
_mcl_autogroup_groupcaps = {
_mcl_diggroups = {
pickaxey = { tool_multiplier = 6, level = 4, uses = 251 }
},
})
@ -160,7 +160,7 @@ minetest.register_tool("mcl_tools:pick_gold", {
sound = { breaks = "default_tool_breaks" },
_repair_material = "mcl_core:gold_ingot",
_mcl_toollike_wield = true,
_mcl_autogroup_groupcaps = {
_mcl_diggroups = {
pickaxey = { tool_multiplier = 12, level = 2, uses = 33 }
},
})
@ -180,7 +180,7 @@ minetest.register_tool("mcl_tools:pick_diamond", {
sound = { breaks = "default_tool_breaks" },
_repair_material = "mcl_core:diamond",
_mcl_toollike_wield = true,
_mcl_autogroup_groupcaps = {
_mcl_diggroups = {
pickaxey = { tool_multiplier = 8, level = 5, uses = 1562 }
},
})
@ -272,7 +272,7 @@ minetest.register_tool("mcl_tools:shovel_wood", {
sound = { breaks = "default_tool_breaks" },
_repair_material = "group:wood",
_mcl_toollike_wield = true,
_mcl_autogroup_groupcaps = {
_mcl_diggroups = {
shovely = { tool_multiplier = 2, level = 1, uses = 60 }
},
})
@ -293,7 +293,7 @@ minetest.register_tool("mcl_tools:shovel_stone", {
sound = { breaks = "default_tool_breaks" },
_repair_material = "mcl_core:cobble",
_mcl_toollike_wield = true,
_mcl_autogroup_groupcaps = {
_mcl_diggroups = {
shovely = { tool_multiplier = 4, level = 3, uses = 132 }
},
})
@ -314,7 +314,7 @@ minetest.register_tool("mcl_tools:shovel_iron", {
sound = { breaks = "default_tool_breaks" },
_repair_material = "mcl_core:iron_ingot",
_mcl_toollike_wield = true,
_mcl_autogroup_groupcaps = {
_mcl_diggroups = {
shovely = { tool_multiplier = 6, level = 4, uses = 251 }
},
})
@ -335,7 +335,7 @@ minetest.register_tool("mcl_tools:shovel_gold", {
sound = { breaks = "default_tool_breaks" },
_repair_material = "mcl_core:gold_ingot",
_mcl_toollike_wield = true,
_mcl_autogroup_groupcaps = {
_mcl_diggroups = {
shovely = { tool_multiplier = 12, level = 2, uses = 33 }
},
})
@ -356,7 +356,7 @@ minetest.register_tool("mcl_tools:shovel_diamond", {
sound = { breaks = "default_tool_breaks" },
_repair_material = "mcl_core:diamond",
_mcl_toollike_wield = true,
_mcl_autogroup_groupcaps = {
_mcl_diggroups = {
shovely = { tool_multiplier = 8, level = 5, uses = 1562 }
},
})
@ -378,7 +378,7 @@ minetest.register_tool("mcl_tools:axe_wood", {
sound = { breaks = "default_tool_breaks" },
_repair_material = "group:wood",
_mcl_toollike_wield = true,
_mcl_autogroup_groupcaps = {
_mcl_diggroups = {
axey = { tool_multiplier = 2, level = 1, uses = 60 }
},
})
@ -397,7 +397,7 @@ minetest.register_tool("mcl_tools:axe_stone", {
sound = { breaks = "default_tool_breaks" },
_repair_material = "mcl_core:cobble",
_mcl_toollike_wield = true,
_mcl_autogroup_groupcaps = {
_mcl_diggroups = {
axey = { tool_multiplier = 4, level = 3, uses = 132 }
},
})
@ -417,7 +417,7 @@ minetest.register_tool("mcl_tools:axe_iron", {
sound = { breaks = "default_tool_breaks" },
_repair_material = "mcl_core:iron_ingot",
_mcl_toollike_wield = true,
_mcl_autogroup_groupcaps = {
_mcl_diggroups = {
axey = { tool_multiplier = 6, level = 4, uses = 251 }
},
})
@ -436,7 +436,7 @@ minetest.register_tool("mcl_tools:axe_gold", {
sound = { breaks = "default_tool_breaks" },
_repair_material = "mcl_core:gold_ingot",
_mcl_toollike_wield = true,
_mcl_autogroup_groupcaps = {
_mcl_diggroups = {
axey = { tool_multiplier = 12, level = 2, uses = 33 }
},
})
@ -455,7 +455,7 @@ minetest.register_tool("mcl_tools:axe_diamond", {
sound = { breaks = "default_tool_breaks" },
_repair_material = "mcl_core:diamond",
_mcl_toollike_wield = true,
_mcl_autogroup_groupcaps = {
_mcl_diggroups = {
axey = { tool_multiplier = 8, level = 5, uses = 1562 }
},
})
@ -477,7 +477,7 @@ minetest.register_tool("mcl_tools:sword_wood", {
sound = { breaks = "default_tool_breaks" },
_repair_material = "group:wood",
_mcl_toollike_wield = true,
_mcl_autogroup_groupcaps = {
_mcl_diggroups = {
swordy = { tool_multiplier = 2, level = 1, uses = 60 },
swordy_cobweb = { tool_multiplier = 2, level = 1, uses = 60 }
},
@ -497,7 +497,7 @@ minetest.register_tool("mcl_tools:sword_stone", {
sound = { breaks = "default_tool_breaks" },
_repair_material = "mcl_core:cobble",
_mcl_toollike_wield = true,
_mcl_autogroup_groupcaps = {
_mcl_diggroups = {
swordy = { tool_multiplier = 4, level = 3, uses = 132 },
swordy_cobweb = { tool_multiplier = 4, level = 3, uses = 132 }
},
@ -517,7 +517,7 @@ minetest.register_tool("mcl_tools:sword_iron", {
sound = { breaks = "default_tool_breaks" },
_repair_material = "mcl_core:iron_ingot",
_mcl_toollike_wield = true,
_mcl_autogroup_groupcaps = {
_mcl_diggroups = {
swordy = { tool_multiplier = 6, level = 4, uses = 251 },
swordy_cobweb = { tool_multiplier = 6, level = 4, uses = 251 }
},
@ -537,7 +537,7 @@ minetest.register_tool("mcl_tools:sword_gold", {
sound = { breaks = "default_tool_breaks" },
_repair_material = "mcl_core:gold_ingot",
_mcl_toollike_wield = true,
_mcl_autogroup_groupcaps = {
_mcl_diggroups = {
swordy = { tool_multiplier = 12, level = 2, uses = 33 },
swordy_cobweb = { tool_multiplier = 12, level = 2, uses = 33 }
},
@ -557,7 +557,7 @@ minetest.register_tool("mcl_tools:sword_diamond", {
sound = { breaks = "default_tool_breaks" },
_repair_material = "mcl_core:diamond",
_mcl_toollike_wield = true,
_mcl_autogroup_groupcaps = {
_mcl_diggroups = {
swordy = { tool_multiplier = 8, level = 5, uses = 1562 },
swordy_cobweb = { tool_multiplier = 8, level = 5, uses = 1562 }
},
@ -579,7 +579,7 @@ minetest.register_tool("mcl_tools:shears", {
on_place = carve_pumpkin,
sound = { breaks = "default_tool_breaks" },
_mcl_toollike_wield = true,
_mcl_autogroup_groupcaps = {
_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 }