Skip to content

Commit

Permalink
Improve steel to iron overrides
Browse files Browse the repository at this point in the history
reduces optional dependencies and extends to support as many items as possible
  • Loading branch information
OgelGames committed Nov 1, 2021
1 parent e7cc399 commit c6433a9
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 176 deletions.
119 changes: 39 additions & 80 deletions technic_worldgen/crafts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ minetest.register_craftitem(":technic:uranium_lump", {
description = S("Uranium Lump"),
inventory_image = "technic_uranium_lump.png",
})
minetest.register_alias("technic:uranium", "technic:uranium_lump")

minetest.register_craftitem(":technic:uranium_ingot", {
description = S("Uranium Ingot"),
inventory_image = "technic_uranium_ingot.png",
groups = {uranium_ingot=1},
groups = {uranium_ingot = 1},
})

minetest.register_craftitem(":technic:chromium_lump", {
Expand Down Expand Up @@ -48,14 +47,6 @@ minetest.register_craftitem(":technic:sulfur_lump", {
inventory_image = "technic_sulfur_lump.png",
})

minetest.register_alias("technic:wrought_iron_ingot", "default:steel_ingot")

minetest.override_item("default:steel_ingot", {
description = S("Wrought Iron Ingot"),
-- make the color of the ingot a bit darker to separate it better from tin
inventory_image = "technic_wrought_iron_ingot.png^[multiply:#bbbbbbff",
})

minetest.register_craftitem(":technic:cast_iron_ingot", {
description = S("Cast Iron Ingot"),
inventory_image = "technic_cast_iron_ingot.png",
Expand All @@ -71,7 +62,21 @@ minetest.register_craftitem(":technic:stainless_steel_ingot", {
inventory_image = "technic_stainless_steel_ingot.png",
})

local function register_block(block, ingot)
local blocks = {
"uranium",
"chromium",
"zinc",
"lead",
"cast_iron",
"carbon_steel",
"stainless_steel",
"sulfur",
}

for _, name in pairs(blocks) do
local block = "technic:"..name.."_block"
local ingot = "technic:"..name.."_ingot"

minetest.register_craft({
output = block,
recipe = {
Expand All @@ -83,112 +88,66 @@ local function register_block(block, ingot)

minetest.register_craft({
output = ingot.." 9",
recipe = {
{block}
}
recipe = {{block}}
})
end

register_block("technic:uranium_block", "technic:uranium_ingot")
register_block("technic:chromium_block", "technic:chromium_ingot")
register_block("technic:zinc_block", "technic:zinc_ingot")
register_block("technic:lead_block", "technic:lead_ingot")
register_block("technic:cast_iron_block", "technic:cast_iron_ingot")
register_block("technic:carbon_steel_block", "technic:carbon_steel_ingot")
register_block("technic:stainless_steel_block", "technic:stainless_steel_ingot")
register_block("technic:sulfur_block", "technic:sulfur_lump")

minetest.register_craft({
type = 'cooking',
type = "cooking",
recipe = "technic:zinc_lump",
output = "technic:zinc_ingot",
})

minetest.register_craft({
type = 'cooking',
type = "cooking",
recipe = "technic:chromium_lump",
output = "technic:chromium_ingot",
})

minetest.register_craft({
type = 'cooking',
type = "cooking",
recipe = "technic:uranium_lump",
output = "technic:uranium_ingot",
})

minetest.register_craft({
type = 'cooking',
type = "cooking",
recipe = "technic:lead_lump",
output = "technic:lead_ingot",
})


minetest.register_craft({
type = 'cooking',
recipe = minetest.registered_aliases["technic:wrought_iron_ingot"],
type = "cooking",
recipe = "default:steel_ingot",
output = "technic:cast_iron_ingot",
})

minetest.register_craft({
type = 'cooking',
type = "cooking",
recipe = "technic:cast_iron_ingot",
cooktime = 2,
output = "technic:wrought_iron_ingot",
})

minetest.register_craft({
type = 'cooking',
type = "cooking",
recipe = "technic:carbon_steel_ingot",
cooktime = 2,
output = "technic:wrought_iron_ingot",
})

local function for_each_registered_item(action)
local already_reg = {}
for k, _ in pairs(minetest.registered_items) do
table.insert(already_reg, k)
end
local really_register_craftitem = minetest.register_craftitem
minetest.register_craftitem = function(name, def)
really_register_craftitem(name, def)
action(string.gsub(name, "^:", ""))
end
local really_register_tool = minetest.register_tool
minetest.register_tool = function(name, def)
really_register_tool(name, def)
action(string.gsub(name, "^:", ""))
end
local really_register_node = minetest.register_node
minetest.register_node = function(name, def)
really_register_node(name, def)
action(string.gsub(name, "^:", ""))
end
for _, name in ipairs(already_reg) do
action(name)
end
end

local steel_to_iron = {}
for _, i in ipairs({
"default:axe_steel",
"default:pick_steel",
"default:shovel_steel",
"default:sword_steel",
"doors:door_steel",
"farming:hoe_steel",
"glooptest:hammer_steel",
"glooptest:handsaw_steel",
"glooptest:reinforced_crystal_glass",
"mesecons_doors:op_door_steel",
"mesecons_doors:sig_door_steel",
"vessels:steel_bottle",
}) do
steel_to_iron[i] = true
end
minetest.register_craft({
output = "technic:marble_bricks 4",
recipe = {
{"technic:marble","technic:marble"},
{"technic:marble","technic:marble"}
}
})

for_each_registered_item(function(item_name)
local item_def = minetest.registered_items[item_name]
if steel_to_iron[item_name] and string.find(item_def.description, "Steel") then
minetest.override_item(item_name, { description = string.gsub(item_def.description, "Steel", S("Iron")) })
end
end)
minetest.register_craft({
output = "technic:granite_bricks 4",
recipe = {
{"technic:granite","technic:granite"},
{"technic:granite","technic:granite"}
}
})
10 changes: 9 additions & 1 deletion technic_worldgen/init.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

local modpath = minetest.get_modpath("technic_worldgen")

technic = rawget(_G, "technic") or {}
Expand All @@ -9,12 +10,13 @@ dofile(modpath.."/config.lua")
dofile(modpath.."/nodes.lua")
dofile(modpath.."/oregen.lua")
dofile(modpath.."/crafts.lua")
dofile(modpath.."/overrides.lua")

-- Rubber trees, moretrees also supplies these
if not minetest.get_modpath("moretrees") then
dofile(modpath.."/rubber.lua")
else
-- older versions of technic provided rubber trees regardless
-- Older versions of technic provided rubber trees regardless
minetest.register_alias("technic:rubber_sapling", "moretrees:rubber_tree_sapling")
minetest.register_alias("technic:rubber_tree_empty", "moretrees:rubber_tree_trunk_empty")
end
Expand All @@ -24,3 +26,9 @@ if minetest.get_modpath("mg") then
dofile(modpath.."/mg.lua")
end

minetest.register_alias("technic:wrought_iron_ingot", "default:steel_ingot")
minetest.register_alias("technic:uranium", "technic:uranium_lump")
minetest.register_alias("technic:wrought_iron_block", "default:steelblock")
minetest.register_alias("technic:diamond_block", "default:diamondblock")
minetest.register_alias("technic:diamond", "default:diamond")
minetest.register_alias("technic:mineral_diamond", "default:stone_with_diamond")
2 changes: 1 addition & 1 deletion technic_worldgen/mod.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name = technic_worldgen
depends = default
optional_depends = intllib, mg, doors, farming, glooptest, mesecons_doors, vessels
optional_depends = intllib, mg
Loading

0 comments on commit c6433a9

Please sign in to comment.