local fragments_per_ingot = 4
minetest.register_lbm {
label = "delete duranium ore again";
name = "sorcery:delete_duranium_ore_again";
nodenames = {'sorcery:stone_with_duranium'};
action = function(pos,node)
minetest.set_node(pos, {name = 'default:stone'})
end
}
sorcery.registry.mk('alloys',false)
sorcery.registry.mk('kilnrecs',false)
sorcery.data.metallookup = {
-- compat bullshit
['moreores:silver_ingot'] = {
id = 'silver'; data = sorcery.data.metals.silver;
value = fragments_per_ingot;
};
['moreores:silver_block'] = {
id = 'silver'; data = sorcery.data.metals.silver;
value = fragments_per_ingot * 9;
};
['basic_materials:brass_ingot'] = {
id = 'brass'; data = sorcery.data.metals.brass;
value = fragments_per_ingot;
};
['basic_materials:brass_block'] = {
id = 'brass'; data = sorcery.data.metals.brass;
value = fragments_per_ingot * 9;
};
['morelights_vintage:brass_ingot'] = {
id = 'brass'; data = sorcery.data.metals.brass;
value = fragments_per_ingot;
};
['morelights_vintage:brass_block'] = {
id = 'brass'; data = sorcery.data.metals.brass;
value = fragments_per_ingot * 9;
};
}
local fmt = string.format
local tools, armors = sorcery.matreg.tools, sorcery.matreg.armors
-- for name, metal in pairs(sorcery.data.metals) do
sorcery.register.metals.foreach('sorcery:generate',{},function(name,metal)
local ingot = metal.ingot or 'sorcery:' .. name .. '_ingot'
local block = metal.block or 'sorcery:' .. name .. 'block'
local screw = 'sorcery:screw_' .. name
local fragment = 'sorcery:fragment_' .. name
local powder = 'sorcery:powder_' .. name
local disc = 'sorcery:disc_' .. name
metal.parts = {
ingot = ingot;
block = block;
screw = screw;
fragment = fragment;
powder = powder;
disc = disc;
}
if not metal.no_tools then for t,c in pairs(tools) do
sorcery.matreg.lookup[(metal.items and metal.items[t]) or ('sorcery:' .. t .. '_' .. name)] = {
metal = true;
id = name; data = metal;
value = c.cost * fragments_per_ingot;
}
end end
if not metal.no_armor then for a,c in pairs(armors) do
sorcery.matreg.lookup[(metal.items and metal.items[a]) or ('sorcery:' .. a .. '_' .. name)] = {
metal = true;
id = name; data = metal;
value = c.cost * fragments_per_ingot;
}
end end
local install = function(part,amt)
sorcery.data.metallookup[part] = { id = name, data = metal, value = amt }
end
install(ingot, fragments_per_ingot)
install(block, fragments_per_ingot*9)
install(fragment, 1)
install(powder, 1)
install(disc, 8/3)
if metal.wire then
if metal.wire == true then
metal.parts.wire = 'sorcery:wire_' .. name
minetest.register_craftitem(metal.parts.wire, {
inventory_image = string.format('basic_materials_empty_spool.png^sorcery_%s_wire.png', name);
description = string.format('Spool of %s wire',name);
groups = {metal = 1, wire = 1};
})
minetest.register_craft {
type = 'shapeless';
output = metal.parts.wire .. ' 2';
recipe = {
metal.parts.ingot;
'basic_materials:empty_spool';
'basic_materials:empty_spool';
}
}
else
metal.parts.wire = metal.wire
end
minetest.register_craft {
type = 'shapeless';
output = metal.parts.wire;
recipe = {
metal.parts.fragment;
metal.parts.fragment;
'basic_materials:empty_spool';
}
}
install(metal.parts.wire, 2)
end
if not metal.no_craftables then
install(screw, 0.5)
minetest.register_craftitem(screw, {
description = sorcery.lib.str.capitalize(name) .. ' Screw';
inventory_image = sorcery.lib.image('sorcery_screw.png'):multiply(sorcery.lib.color(metal.tone)):render();
groups = { metal = 1; sorcery_screw = 1; sorcery_tech_component = 1; };
_sorcery = {
material = {
id = name, data = metal;
powder = powder;
grindcost = 2, grindvalue = 1;
value = 0.5;
};
};
})
local reglathe = function(ty, sz)
sorcery.lathe.register {
input = ty;
output = {name = screw, count = sz * 2};
tech = 'cut', cost = 1;
}
end
reglathe(fragment, 1)
reglathe(ingot, 4)
reglathe(block, 4 * 9)
end
minetest.register_craftitem(disc, {
description = sorcery.lib.str.capitalize(name) .. ' Disc';
inventory_image = fmt('sorcery_disc_%s.png', name);
groups = { metal = 1; sorcery_disc = 1; sorcery_tech_component = 1; };
_sorcery = {
material = {
id = name, data = metal;
powder = powder;
grindcost = 3;
grindvalue = 2*4;
value = 4 * (2/3);
};
};
})
sorcery.lathe.register {
input = ingot;
output = {name = fragment; count = fragments_per_ingot};
tech = 'cut', cost = 2;
}
sorcery.lathe.register {
input = block;
output = {name = fragment; count = fragments_per_ingot*9};
tech = 'cut', cost = 2*7;
}
sorcery.lathe.register {
input = ingot, mass = 2;
output = {name = disc, count = 3};
tech = 'cut', cost = 5;
}
sorcery.lathe.register {
input = block;
output = {name = disc, count = 8*3};
leftover = ingot;
tech = 'cut', cost = 5*7;
}
minetest.register_craftitem(powder, {
description = sorcery.lib.str.capitalize(name) .. ' Powder';
inventory_image = 'sorcery_' .. name .. '_powder.png';
groups = {sorcery_powder = 1; powder = 1};
})
if metal.dye then
minetest.register_craft {
output = 'dye:' .. metal.dye .. ' 4';
recipe = {
{'', powder, ''};
{powder,'basic_materials:paraffin',powder};
{'', 'bucket:bucket_water', ''};
};
replacements = {
{'bucket:bucket_water', 'bucket:bucket_empty'};
};
};
end
if not sorcery.compat.defp(ingot) then
-- TODO: remove instant_ores dependency
instant_ores.register_metal {
name = 'sorcery:' .. name;
description = sorcery.lib.str.capitalize(name);
color = sorcery.lib.color(metal.tone):hex() .. ':' .. ((metal.alpha and tostring(metal.alpha)) or '45');
rarity = metal.rarity;
depth = metal.depth;
no_armor = metal.no_armor;
no_tools = metal.no_tools;
durability = metal.durability;
power = metal.power;
speed = metal.speed;
artificial = metal.artificial;
cooktime = metal.cooktime;
hardness = (metal.hardness/8) * 3; -- scaled wrt diamond
level = math.ceil(((metal.hardness/8) * 3)) + 1;
ingot_image = (metal.image and metal.image.ingot) or nil;
block_image = (metal.image and metal.image.block) or nil;
ore_image = 'default_stone.png^sorcery_' .. name .. '_ore.png';
lump_image = (metal.image and metal.image.lump) or nil;
armor_weight = metal.armor_weight;
armor_protection = metal.armor_protection;
}
end
local ti = (metal.image and metal.image.tool)
for _,t in pairs{'pick','sword'} do
-- i really need to rip out instant-ores already
local tid = string.format('sorcery:%s_%s',t,name)
if minetest.registered_items[tid] then
minetest.override_item(tid, {
inventory_image = ti and ti.pick or string.format('sorcery_%s_%s.png',name,t);
})
end
end
minetest.register_craftitem(fragment, {
inventory_image = 'sorcery_' .. name .. '_fragment.png';
description = sorcery.lib.str.capitalize(name) .. ' Fragment';
groups = {
metal = 1; sorcery_metal_fragment = 1;
};
_sorcery = {
recipe = {
canonical = {
cook = {{ingot}};
};
};
};
})
minetest.register_craft {
type = 'cooking';
recipe = powder;
cooktime = (metal.cooktime or 4) * 0.25;
output = fragment;
}
minetest.register_craft {
type = 'cooking';
recipe = ingot;
cooktime = (metal.cooktime or 4) * 0.5;
output = fragment .. ' ' .. tostring(fragments_per_ingot);
}
do local rec = {}
for i=1,fragments_per_ingot do
rec[#rec+1]=fragment
end
minetest.register_craft {
type = 'shapeless';
recipe = rec;
output = ingot;
}
end
if metal.fuel then
minetest.register_craft {
type = 'fuel';
recipe = powder;
burntime = metal.fuel;
}
end
if metal.mix then
sorcery.register.alloys.link(sorcery.lib.tbl.merge(metal.mix, {
output = name;
cooktime = metal.cooktime or 10;
}))
end
if metal.sinter then
local powders = {}
for _,m in pairs(metal.sinter) do
powders[#powders+1] = 'sorcery:powder_' .. m
end
local repl = {}
if metal.sinter_catalyst then
for _,m in pairs(metal.sinter_catalyst) do
powders[#powders+1] = m
if sorcery.register.residue.db[m] then
repl[#repl+1] = {m, sorcery.register.residue.db[m]}
end
end
end
minetest.register_craft {
type = 'shapeless';
output = powder .. ' ' .. tostring(#metal.sinter);
recipe = powders;
replacements = repl;
};
end
end)