1ef418acfc
When this was setup, it was named generically in order to support future functionality that used the same heating/tempering/annealing mechanics. Ironically this has actually only caused problems. Standard game mechanics will not mimic one another, especially something this complex. Anything worth making a system for nodecore that's as complex as lode-working deserves its own distinct mechanics rather than recycling lode-working. So vanilla NC will not reuse the metal-working logic anyway. Mods were able to reuse the existing logic, but ironically the only one mod that would actually have benefitted from it (i.e. uses very similar heating/tempering/annealing) just copied and pasted the code from NodeCore anyway, which not only didn't take advantage of the existing mechanic provided, but actually made the mod break the game when installed, because the mod would replace functionality in use by vanilla with an older version, and the copying will always keep that functionality locked in to an older version, breaking whenever future changes to the base mechanic are made. Rename the base mechanic to (1) get out of the way of the existing mod, and (2) make it more clear that this is NOT generic functionality that can be used to create new metals, but only specifically for lode, and if somebody else wants a clone of this logic, they would need to rename it to make sense.
138 lines
3.7 KiB
Lua
138 lines
3.7 KiB
Lua
-- LUALOCALS < ---------------------------------------------------------
|
|
local ipairs, minetest, nodecore, pairs, type
|
|
= ipairs, minetest, nodecore, pairs, type
|
|
-- LUALOCALS > ---------------------------------------------------------
|
|
|
|
local modname = minetest.get_current_modname()
|
|
|
|
local function toolhead(name, groups, prills)
|
|
local n = name:lower()
|
|
|
|
if type(groups) == "string" then groups = {groups} end
|
|
local function toolcap(nn)
|
|
local t = {}
|
|
for _, k in ipairs(groups) do t[k] = nn end
|
|
return nodecore.toolcaps(t)
|
|
end
|
|
|
|
nodecore.register_lode("toolhead_" .. n, {
|
|
type = "craft",
|
|
description = "## Lode " .. name .. " Head",
|
|
inventory_image = modname .. "_#.png^[mask:" ..
|
|
modname .. "_toolhead_" .. n .. ".png",
|
|
stack_max = 1,
|
|
tool_head_capabilities = toolcap(4),
|
|
bytemper = function(t, d)
|
|
if t.name == "tempered" then
|
|
d.tool_head_capabilities = toolcap(5)
|
|
else if t.name == "hot" then
|
|
d.tool_head_capabilities = toolcap(3)
|
|
end
|
|
end
|
|
end
|
|
})
|
|
|
|
nodecore.register_lode("tool_" .. n, {
|
|
type = "tool",
|
|
description = "## Lode " .. name,
|
|
inventory_image = modname .. "_tool_handle.png^(" ..
|
|
modname .. "_#.png^[mask:" ..
|
|
modname .. "_tool_" .. n .. ".png)",
|
|
stack_max = 1,
|
|
tool_capabilities = toolcap(4),
|
|
bytemper = function(t, d)
|
|
if t.name == "tempered" then
|
|
d.tool_capabilities = toolcap(5)
|
|
end
|
|
d.skip_register = (t.name == "hot") or nil
|
|
end,
|
|
groups = {flammable = 4},
|
|
lode_alt_hot = modname .. ":prill_hot " .. prills,
|
|
tool_wears_to = prills > 1 and (modname .. ":prill_# " .. (prills - 1)) or nil,
|
|
on_ignite = modname .. ":prill_# " .. prills
|
|
})
|
|
|
|
for _, t in pairs({"annealed", "tempered"}) do
|
|
nodecore.register_craft({
|
|
label = "assemble lode " .. n,
|
|
normal = {y = 1},
|
|
indexkeys = {modname .. ":toolhead_" .. n .. "_" .. t},
|
|
nodes = {
|
|
{match = modname .. ":toolhead_" .. n .. "_" .. t,
|
|
replace = "air"},
|
|
{y = -1, match = "nc_woodwork:staff", replace = "air"},
|
|
},
|
|
items = {
|
|
{y = -1, name = modname .. ":tool_" .. n .. "_" .. t},
|
|
}
|
|
})
|
|
end
|
|
end
|
|
|
|
toolhead("Mallet", "thumpy", 3)
|
|
toolhead("Spade", "crumbly", 2)
|
|
toolhead("Hatchet", "choppy", 2)
|
|
toolhead("Pick", "cracky", 1)
|
|
|
|
local function forge(from, fromqty, to, prills)
|
|
return nodecore.register_lode_anvil_recipe(-1, function(temper)
|
|
return {
|
|
label = "forge lode " .. (to or "prills"),
|
|
action = "pummel",
|
|
toolgroups = {thumpy = 3},
|
|
indexkeys = {modname .. ":" .. from .. "_" .. temper},
|
|
nodes = {
|
|
{
|
|
match = {
|
|
name = modname .. ":" .. from .. "_" .. temper,
|
|
count = fromqty
|
|
},
|
|
replace = "air"
|
|
}
|
|
},
|
|
items = {
|
|
to and (modname .. ":" .. to .. "_" .. temper) or nil,
|
|
prills and {
|
|
name = modname .. ":prill_" .. temper,
|
|
count = prills,
|
|
scatter = 5
|
|
} or nil
|
|
}
|
|
}
|
|
end)
|
|
end
|
|
|
|
forge("prill", 3, "toolhead_mallet")
|
|
forge("toolhead_mallet", nil, "toolhead_spade", 1)
|
|
forge("toolhead_spade", nil, "toolhead_hatchet")
|
|
forge("toolhead_hatchet", nil, "toolhead_pick", 1)
|
|
forge("toolhead_pick", nil, nil, 1)
|
|
|
|
toolhead("Mattock", {"cracky", "crumbly"}, 3)
|
|
local function mattock(a, b)
|
|
return nodecore.register_craft({
|
|
label = "assemble lode mattock head",
|
|
action = "pummel",
|
|
toolgroups = {thumpy = 3},
|
|
normal = {y = 1},
|
|
indexkeys = {modname .. (a == 0 and ":toolhead_pick_hot" or ":toolhead_spade_hot")},
|
|
nodes = {
|
|
{
|
|
y = a,
|
|
match = modname .. ":toolhead_pick_hot",
|
|
replace = "air"
|
|
},
|
|
{
|
|
y = b,
|
|
match = modname .. ":toolhead_spade_hot",
|
|
replace = "air"
|
|
}
|
|
},
|
|
items = {
|
|
modname .. ":toolhead_mattock_hot"
|
|
}
|
|
})
|
|
end
|
|
mattock(0, -1)
|
|
mattock(-1, 0)
|