minor tweaks

This commit is contained in:
flux 2023-04-01 14:19:16 -07:00
parent 1876d82e1d
commit 82f0e25969
No known key found for this signature in database
GPG Key ID: 9333B27816848A15

View File

@ -44,15 +44,17 @@ toolcap_monoids.dig_speed = item_monoids.make_monoid("dig_speed", {
end end
end end
for group, times in pairs(dig_speeds) do for group, times in pairs(dig_speeds) do
if not tool_capabilities.groupcaps[group] then local groupcap = tool_capabilities.groupcaps[group]
if not groupcap then
local default_caps = toolstack:get_definition().tool_capabilities.groupcaps[group] local default_caps = toolstack:get_definition().tool_capabilities.groupcaps[group]
if default_caps then if default_caps then
tool_capabilities.groupcaps[group] = table.copy(default_caps) groupcap = table.copy(default_caps)
else else
tool_capabilities.groupcaps[group] = {} groupcap = {}
end end
tool_capabilities.groupcaps[group] = groupcap
end end
tool_capabilities.groupcaps[group].times = times groupcap.times = times
end end
local meta = toolstack:get_meta() local meta = toolstack:get_meta()
meta:set_tool_capabilities(tool_capabilities) meta:set_tool_capabilities(tool_capabilities)
@ -164,7 +166,7 @@ toolcap_monoids.damage = item_monoids.make_monoid("damage", {
damage_groups[group] = "disabled" damage_groups[group] = "disabled"
elseif damage_groups[group] ~= "disabled" then elseif damage_groups[group] ~= "disabled" then
local total_damage = (damage_groups[group] or 0) + damage local total_damage = (damage_groups[group] or 0) + damage
if total_damage == 0 then if total_damage <= 0 then
damage_groups[group] = nil damage_groups[group] = nil
else else
damage_groups[group] = total_damage damage_groups[group] = total_damage