mirror of
https://git.minetest.land/Mineclonia/Mineclonia.git
synced 2024-11-24 08:55:12 +00:00
Add digging time support for shears/swords/hand
This commit is contained in:
parent
a4a6ec9b06
commit
b05c56bcd3
1 changed files with 24 additions and 2 deletions
|
@ -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 a new issue