1
0
Fork 0

Write comment explaining mcl_autogroup magic

This commit is contained in:
Wuzzy 2017-02-26 19:38:40 +01:00
parent c668d98c87
commit a4a6ec9b06
1 changed files with 41 additions and 0 deletions

View File

@ -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 <http://minecraft.gamepedia.com/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