Add exclusive use for infused rake

Recalculate rake function based on update tool
capabilities so rakes can work on pumice now, and
theoretically even a future snappy=3 material.
This commit is contained in:
Aaron Suen 2020-09-06 17:48:47 -04:00
parent 6e9865487c
commit 3915426d7b
2 changed files with 15 additions and 9 deletions

View File

@ -11,14 +11,15 @@ local loosetest = nodecore.rake_index(function(def)
and def.groups.snappy == 1
end)
local snapvol = nodecore.rake_volume(1, 1)
local snaptest = nodecore.rake_index(function(def)
return def.groups and def.groups.snappy == 1
end)
local crumbvol = nodecore.rake_volume(1, 0)
local function mkonrake(crumblv)
local function mkonrake(toolcaps)
local snaptest = nodecore.rake_index(function(def)
return def.groups and def.groups.snappy
and def.groups.snappy <= toolcaps.opts.snappy
end)
local crumbtest = nodecore.rake_index(function(def)
return def.groups and def.groups.crumbly
and def.groups.crumbly <= crumblv
and def.groups.crumbly <= toolcaps.opts.crumbly
end)
return function(pos, node)
if loosetest(pos, node) then return loosevol, loosetest end
@ -26,6 +27,7 @@ local function mkonrake(crumblv)
if crumbtest(pos, node) then return crumbvol, crumbtest end
end
end
nodecore.lode_rake_function = mkonrake
nodecore.register_lode("rake", {
type = "tool",
@ -45,7 +47,7 @@ nodecore.register_lode("rake", {
crumbly = 1 + dlv,
uses = 20 + 5 * dlv
})
d.on_rake = mkonrake(1 + dlv)
d.on_rake = mkonrake(d.tool_capabilities)
end,
tool_wears_to = modname .. ":prill_# 12"
})

View File

@ -29,25 +29,29 @@ local function mktool(tshape, buffs)
def.after_use = nil
def.groups = nodecore.underride({lux_tool = 1, lux_emit = 1}, orig.groups or {})
local tc = {}
for k, v in pairs(orig.tool_capabilities.opts) do
tc[k] = v + 1 + (buffs[k] or 0)
end
tc.uses = 0.125
def.tool_capabilities = nodecore.toolcaps(tc)
if def.on_rake then
def.on_rake = nodecore.lode_rake_function(def.tool_capabilities)
end
for k, v in pairs(orig.tool_capabilities.opts) do
tc[k] = v + 2 + (buffs[k] or 0)
end
local boosttc = nodecore.toolcaps(tc)
local boost = nodecore.underride({
inventory_image = orig.inventory_image .. "^(" .. modname
.. "_base.png^[mask:" .. modname
.. "_infuse_mask.png^[mask:nc_lode_" .. tshape
.. ".png^[opacity:120])",
tool_capabilities = nodecore.toolcaps(tc),
tool_capabilities = boosttc,
glow = 2,
light_source = 1
light_source = 1,
on_rake = def.on_rake and nodecore.lode_rake_function(boosttc)
}, def)
boost.groups = nodecore.underride({lux_tool = 1, lux_emit = 2}, def.groups)