From a4a6ec9b067ee3f2e91c94ce8e436c86eb1a7863 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sun, 26 Feb 2017 19:38:40 +0100 Subject: [PATCH] Write comment explaining mcl_autogroup magic --- mods/CORE/mcl_autogroup/init.lua | 41 ++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/mods/CORE/mcl_autogroup/init.lua b/mods/CORE/mcl_autogroup/init.lua index 8348bd03..fb3de5f4 100644 --- a/mods/CORE/mcl_autogroup/init.lua +++ b/mods/CORE/mcl_autogroup/init.lua @@ -1,3 +1,42 @@ +--[[ This mod automatically adds groups to items based on item metadata. + +Specifically, this mod has 2 purposes: +1) Automatically adding the group “solid” for blocks considered “solid” in Minecraft. +2) Generating digging time group for all nodes based on node metadata (it's complicated) + +]] + +--[[ Mining times. Yeah, mining times … Alright, this is going to be FUN! + +This mod does include a HACK to make 100% sure the digging times of all tools match Minecraft's perfectly. +The digging times system of Minetest is very different, so this weird group trickery has to be used.so this weird group trickery has to be used.so this weird group trickery has to be used.so this weird group trickery has to be used. +In Minecraft, each block has a hardness and the actual Minecraft digging time is determined by this: +1) The block's hardness +2) The tool being used +3) Whether the tool is considered as “eligible” for the block + (e.g. only diamond pick eligible for obsidian) +See Minecraft Wiki for more information. + +In MineClone 2, all diggable node have the hardness set in the custom field “_mcl_hardness” (0 by default). +The nodes are also required to specify the “eligible” tools in groups like “pickaxey”, “shovely”, etc. +This mod then calculates the real digging time based on the node meta data. The real digging times +are then added into mcl_autogroup.digtimes where the table indices are group rating and the values are the +digging times in seconds. These digging times can be then added verbatim into the tool definitions. + +Example: +mcl_autogroup.digtimes.pickaxey_dig_diamond[1] = 0.2 + +→ This menas that when a node has been assigned the group “pickaxey_dig_diamond=1”, it can be dug by the +diamond pickaxe in 0.2 seconds. + + + +This strange setup with mcl_autogroup has been done to minimize the amount of required digging times +a single tool needs to use. If this is not being done, the loading time will increase considerably +(>10s). + +]] + local materials = { "wood", "gold", "stone", "iron", "diamond" } local material_divisors = { 2, 12, 4, 6, 8 } local basegroups = { "pickaxey", "axey", "shovely" } @@ -15,6 +54,8 @@ for g=1, #minigroups do mcl_autogroup.digtimes[minigroups[g].."_dig"] = {} end + + local overwrite = function() for nname, ndef in pairs(minetest.registered_nodes) do local groups_changed = false