mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-11-28 13:53:45 +01:00
Add digging time support for shears/swords/hand
This commit is contained in:
parent
a4a6ec9b06
commit
b05c56bcd3
@ -41,6 +41,7 @@ local materials = { "wood", "gold", "stone", "iron", "diamond" }
|
||||
local material_divisors = { 2, 12, 4, 6, 8 }
|
||||
local basegroups = { "pickaxey", "axey", "shovely" }
|
||||
local minigroups = { "handy", "shearsy", "swordy" }
|
||||
local minigroup_divisors = { 1, 15, 1.5, 5, 15 }
|
||||
|
||||
mcl_autogroup = {}
|
||||
mcl_autogroup.digtimes = {}
|
||||
@ -54,8 +55,6 @@ 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
|
||||
@ -112,6 +111,29 @@ local overwrite = function()
|
||||
end
|
||||
end
|
||||
end
|
||||
for m=1, #minigroups do
|
||||
local minigroup = minigroups[m]
|
||||
if (hardness ~= -1 and ndef.groups[minigroup]) then
|
||||
local diggroup = minigroup.."_dig"
|
||||
local time, validity_factor
|
||||
if ndef.groups[minigroup] == 1 then
|
||||
-- Valid tool
|
||||
validity_factor = 1.5
|
||||
else
|
||||
-- Wrong tool (higher digging time)
|
||||
validity_factor = 5
|
||||
end
|
||||
time = (hardness * validity_factor) / minigroup_divisors[m]
|
||||
if time <= 0.05 then
|
||||
time = 1
|
||||
else
|
||||
time = math.ceil(time * 20) / 20
|
||||
end
|
||||
table.insert(mcl_autogroup.digtimes[diggroup], time)
|
||||
newgroups[diggroup] = #mcl_autogroup.digtimes[diggroup]
|
||||
groups_changed = true
|
||||
end
|
||||
end
|
||||
|
||||
if groups_changed then
|
||||
minetest.override_item(nname, {
|
||||
|
Loading…
Reference in New Issue
Block a user