From 9bb39dfba6aabacba38256b8946ef5afd06b0d0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20=C3=85str=C3=B6m?= Date: Tue, 16 Mar 2021 20:36:38 +0100 Subject: [PATCH] Rename _mcl_autogroup_groupcaps to _mcl_diggroups --- API.md | 4 +-- mods/CORE/_mcl_autogroup/init.lua | 28 ++++++++-------- mods/ENTITIES/mcl_item_entity/init.lua | 2 +- mods/ITEMS/mcl_tools/init.lua | 44 +++++++++++++------------- 4 files changed, 38 insertions(+), 40 deletions(-) diff --git a/API.md b/API.md index 131effe4..d82a2547 100644 --- a/API.md +++ b/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: diff --git a/mods/CORE/_mcl_autogroup/init.lua b/mods/CORE/_mcl_autogroup/init.lua index c01ba269..400f0d11 100644 --- a/mods/CORE/_mcl_autogroup/init.lua +++ b/mods/CORE/_mcl_autogroup/init.lua @@ -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) diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index 28981fa7..81ef049e 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -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 diff --git a/mods/ITEMS/mcl_tools/init.lua b/mods/ITEMS/mcl_tools/init.lua index dfe872ad..da7c06a3 100644 --- a/mods/ITEMS/mcl_tools/init.lua +++ b/mods/ITEMS/mcl_tools/init.lua @@ -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 }