-local use_factor = 1.2
-local times_subtractor = 0.1
-local sharp_factor = 1
-
-function enchanting.register_enchtools()
- local materials = {"steel", "bronze", "mese", "diamond"}
- local tools = { {"axe", "choppy"}, {"pick", "cracky"}, {"shovel", "crumbly"}, {"sword", "fleshy"} }
- local chants = {"durable", "fast", "sharp"}
-
- for _, m in pairs(materials) do
- for k, t in pairs(tools) do
- for _, c in pairs(chants) do
- local original_tool = minetest.registered_tools["default:"..t[1].."_"..m]
- local original_damage_groups = original_tool.tool_capabilities.damage_groups
- local original_groupcaps = original_tool.tool_capabilities.groupcaps
- local groupcaps = table.copy(original_groupcaps)
- local fleshy = original_damage_groups.fleshy
-
- if c == "durable" and k <= 3 then
- groupcaps[t[2]].uses = original_groupcaps[t[2]].uses * use_factor
- elseif c == "fast" and k <= 3 then
- for i = 1, 3 do
- groupcaps[t[2]].times[i] = original_groupcaps[t[2]].times[i] - times_subtractor
+enchanting.uses = 1.2
+enchanting.times = 0.1
+enchanting.damages = 1
+enchanting.strength = 1.2
+enchanting.speed = 0.2
+enchanting.jump = 0.2
+
+local tools = {
+ --[[ Registration format:
+ [Mod name] = {
+ materials,
+ {tool name, tool group, enchantments}
+ }
+ --]]
+ ["default"] = {
+ "steel, bronze, mese, diamond",
+ {"axe", "choppy", "durable, fast"},
+ {"pick", "cracky", "durable, fast"},
+ {"shovel", "crumbly", "durable, fast"},
+ {"sword", "fleshy", "sharp"}
+ },
+ ["3d_armor"] = {
+ "steel, bronze, gold, diamond",
+ {"boots", nil, "strong, speed"},
+ {"chestplate", nil, "strong"},
+ {"helmet", nil, "strong"},
+ {"leggings", nil, "strong"}
+ }
+}
+
+for mod, defs in pairs(tools) do
+for material in defs[1]:gmatch("[%w_]+") do
+for _, tooldef in next, defs, 1 do
+for enchant in tooldef[3]:gmatch("[%w_]+") do
+ local tool, group = tooldef[1], tooldef[2]
+ local original_tool = minetest.registered_tools[mod..":"..tool.."_"..material]
+
+ if original_tool then
+ if mod == "default" then
+ local original_damage_groups = original_tool.tool_capabilities.damage_groups
+ local original_groupcaps = original_tool.tool_capabilities.groupcaps
+ local groupcaps = table.copy(original_groupcaps)
+ local fleshy = original_damage_groups.fleshy
+ local full_punch_interval = original_tool.tool_capabilities.full_punch_interval
+ local max_drop_level = original_tool.tool_capabilities.max_drop_level
+
+ if enchant == "durable" then
+ groupcaps[group].uses = math.ceil(original_groupcaps[group].uses * enchanting.uses)
+ elseif enchant == "fast" then
+ for i = 1, 3 do
+ groupcaps[group].times[i] = original_groupcaps[group].times[i] - enchanting.times
+ end
+ elseif enchant == "sharp" then
+ fleshy = fleshy + enchanting.damages