2019-01-27 22:34:53 -05:00
|
|
|
-- LUALOCALS < ---------------------------------------------------------
|
2019-10-06 10:31:58 -04:00
|
|
|
local ItemStack, minetest, nodecore, pairs, type
|
|
|
|
= ItemStack, minetest, nodecore, pairs, type
|
2019-01-27 22:34:53 -05:00
|
|
|
-- LUALOCALS > ---------------------------------------------------------
|
|
|
|
|
2019-01-27 09:19:07 -05:00
|
|
|
local modname = minetest.get_current_modname()
|
|
|
|
|
2019-04-03 07:40:19 -04:00
|
|
|
local tempers = {
|
|
|
|
{
|
|
|
|
name = "hot",
|
|
|
|
desc = "Glowing",
|
|
|
|
sound = "annealed",
|
|
|
|
glow = true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name = "annealed",
|
|
|
|
desc = "Annealed",
|
|
|
|
sound = "annealed"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name = "tempered",
|
|
|
|
desc = "Tempered",
|
|
|
|
sound = "tempered"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-03 08:58:27 -05:00
|
|
|
function nodecore.register_lode(shape, rawdef)
|
2019-04-03 07:40:19 -04:00
|
|
|
for _, temper in pairs(tempers) do
|
2019-01-27 09:19:07 -05:00
|
|
|
local def = nodecore.underride({}, rawdef)
|
|
|
|
def = nodecore.underride(def, {
|
2019-04-03 07:40:19 -04:00
|
|
|
description = temper.desc .. " Lode " .. shape,
|
|
|
|
name = (shape .. "_" .. temper.name):lower():gsub(" ", "_"),
|
2019-09-07 12:00:33 -04:00
|
|
|
groups = {
|
|
|
|
cracky = 3,
|
|
|
|
falling_node = temper.name == "hot" and 1 or nil
|
|
|
|
},
|
2019-04-03 07:40:19 -04:00
|
|
|
["metal_temper_" .. temper.name] = true,
|
2019-01-27 22:34:53 -05:00
|
|
|
metal_alt_hot = modname .. ":" .. shape:lower() .. "_hot",
|
|
|
|
metal_alt_annealed = modname .. ":" .. shape:lower() .. "_annealed",
|
|
|
|
metal_alt_tempered = modname .. ":" .. shape:lower() .. "_tempered",
|
2019-04-03 07:40:19 -04:00
|
|
|
sounds = nodecore.sounds("nc_lode_" .. temper.sound)
|
2019-01-27 09:19:07 -05:00
|
|
|
})
|
2019-03-22 22:55:30 -04:00
|
|
|
def.metal_temper_cool = (not def.metal_temper_hot) or nil
|
2019-04-03 07:40:19 -04:00
|
|
|
if not temper.glow then
|
2019-01-27 09:19:07 -05:00
|
|
|
def.light_source = nil
|
|
|
|
else
|
|
|
|
def.groups = def.groups or {}
|
|
|
|
def.groups.falling_node = 1
|
2020-02-19 19:55:22 -05:00
|
|
|
def.damage_per_second = 1
|
2019-01-27 09:19:07 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
if def.tiles then
|
|
|
|
local t = {}
|
|
|
|
for k, v in pairs(def.tiles) do
|
2019-04-03 07:40:19 -04:00
|
|
|
t[k] = v:gsub("#", temper.name)
|
2019-01-27 09:19:07 -05:00
|
|
|
end
|
|
|
|
def.tiles = t
|
|
|
|
end
|
2019-02-19 23:53:40 -05:00
|
|
|
for k, v in pairs(def) do
|
|
|
|
if type(v) == "string" then
|
2019-04-03 07:40:19 -04:00
|
|
|
def[k] = v:gsub("##", temper.desc):gsub("#", temper.name)
|
2019-02-19 23:53:40 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-04-03 08:10:03 -04:00
|
|
|
if def.bytemper then def.bytemper(temper, def) end
|
2019-01-27 09:19:07 -05:00
|
|
|
|
2019-11-17 08:55:24 -05:00
|
|
|
if not def.skip_register then
|
|
|
|
local fullname = modname .. ":" .. def.name
|
|
|
|
minetest.register_item(fullname, def)
|
|
|
|
if def.type == "node" then
|
|
|
|
nodecore.register_cook_abm({nodenames = {fullname}})
|
|
|
|
end
|
2019-09-07 12:00:33 -04:00
|
|
|
end
|
2019-01-27 09:19:07 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-03-08 14:42:04 -05:00
|
|
|
nodecore.register_lode("Block", {
|
2019-01-27 09:19:07 -05:00
|
|
|
type = "node",
|
2019-04-02 08:10:17 -04:00
|
|
|
description = "## Lode",
|
2019-12-01 11:08:12 -05:00
|
|
|
tiles = {modname .. "_#.png"},
|
2019-01-29 20:41:29 -05:00
|
|
|
light_source = 8,
|
|
|
|
crush_damage = 4
|
2019-01-27 22:34:53 -05:00
|
|
|
})
|
|
|
|
|
2019-02-03 08:58:27 -05:00
|
|
|
nodecore.register_lode("Prill", {
|
|
|
|
type = "craft",
|
|
|
|
inventory_image = modname .. "_#.png^[mask:" .. modname .. "_mask_prill.png",
|
|
|
|
})
|
|
|
|
|
2019-03-22 22:55:30 -04:00
|
|
|
local function replacestack(pos, alt)
|
|
|
|
local stack = nodecore.stack_get(pos)
|
2019-09-07 12:00:33 -04:00
|
|
|
if stack:is_empty() then stack = nil end
|
|
|
|
local node = minetest.get_node(pos)
|
|
|
|
local name = stack and stack:get_name() or node.name
|
|
|
|
local def = minetest.registered_items[name] or {}
|
|
|
|
alt = def["metal_alt_" .. alt]
|
|
|
|
if not alt then return nodecore.remove_node(pos) end
|
|
|
|
if stack then
|
|
|
|
local repl = ItemStack(alt)
|
|
|
|
local qty = stack:get_count()
|
|
|
|
if qty == 0 then qty = 1 end
|
|
|
|
repl:set_count(qty * repl:get_count())
|
|
|
|
nodecore.remove_node(pos)
|
|
|
|
return nodecore.item_eject(pos, repl)
|
|
|
|
else
|
|
|
|
nodecore.set_node(pos, {name = alt})
|
2019-09-09 07:05:01 -04:00
|
|
|
nodecore.fallcheck(pos)
|
2019-09-07 12:00:33 -04:00
|
|
|
end
|
2019-01-27 22:34:53 -05:00
|
|
|
end
|
|
|
|
|
2019-03-22 22:55:30 -04:00
|
|
|
nodecore.register_craft({
|
|
|
|
label = "lode stack heating",
|
|
|
|
action = "cook",
|
|
|
|
touchgroups = {flame = 3},
|
|
|
|
duration = 30,
|
|
|
|
cookfx = true,
|
2019-04-13 23:39:46 -04:00
|
|
|
nodes = {{match = {metal_temper_cool = true, count = false}}},
|
2019-03-22 22:55:30 -04:00
|
|
|
after = function(pos) return replacestack(pos, "hot") end
|
|
|
|
})
|
|
|
|
|
|
|
|
nodecore.register_craft({
|
|
|
|
label = "lode stack annealing",
|
|
|
|
action = "cook",
|
|
|
|
touchgroups = {flame = 0},
|
|
|
|
duration = 120,
|
|
|
|
priority = -1,
|
|
|
|
cookfx = {smoke = true, hiss = true},
|
2019-04-13 23:39:46 -04:00
|
|
|
nodes = {{match = {metal_temper_hot = true, count = false}}},
|
2019-03-22 22:55:30 -04:00
|
|
|
after = function(pos) return replacestack(pos, "annealed") end
|
|
|
|
})
|
|
|
|
|
|
|
|
nodecore.register_craft({
|
|
|
|
label = "lode stack quenching",
|
|
|
|
action = "cook",
|
|
|
|
touchgroups = {flame = 0},
|
|
|
|
check = function(pos)
|
2019-11-30 10:28:35 -05:00
|
|
|
return nodecore.quenched(pos)
|
2019-03-22 22:55:30 -04:00
|
|
|
end,
|
|
|
|
cookfx = true,
|
2019-04-13 23:39:46 -04:00
|
|
|
nodes = {{match = {metal_temper_hot = true, count = false}}},
|
2019-03-22 22:55:30 -04:00
|
|
|
after = function(pos) return replacestack(pos, "tempered") end
|
|
|
|
})
|
2019-02-19 23:53:40 -05:00
|
|
|
|
|
|
|
-- Because of how massive they are, forging a block is a hot-working process.
|
|
|
|
nodecore.register_craft({
|
|
|
|
label = "forge lode block",
|
|
|
|
action = "pummel",
|
|
|
|
toolgroups = {thumpy = 3},
|
|
|
|
nodes = {
|
|
|
|
{
|
2019-02-23 09:44:22 -05:00
|
|
|
match = {name = modname .. ":prill_hot", count = 8},
|
2019-02-19 23:53:40 -05:00
|
|
|
replace = "air"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
items = {
|
|
|
|
modname .. ":block_hot"
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
-- Blocks can be chopped back into prills using only hardened tools.
|
|
|
|
nodecore.register_craft({
|
|
|
|
label = "break apart lode block",
|
|
|
|
action = "pummel",
|
|
|
|
toolgroups = {choppy = 5},
|
|
|
|
nodes = {
|
|
|
|
{
|
2019-09-07 14:34:09 -04:00
|
|
|
match = modname .. ":block_hot",
|
2019-02-19 23:53:40 -05:00
|
|
|
replace = "air"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
items = {
|
2019-09-07 14:34:09 -04:00
|
|
|
{name = modname .. ":prill_hot 2", count = 4, scatter = 5}
|
2019-02-19 23:53:40 -05:00
|
|
|
}
|
|
|
|
})
|