Skip to content

Commit c6433a9

Browse files
committed
Improve steel to iron overrides
reduces optional dependencies and extends to support as many items as possible
1 parent e7cc399 commit c6433a9

File tree

5 files changed

+157
-176
lines changed

5 files changed

+157
-176
lines changed

technic_worldgen/crafts.lua

+39-80
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ minetest.register_craftitem(":technic:uranium_lump", {
55
description = S("Uranium Lump"),
66
inventory_image = "technic_uranium_lump.png",
77
})
8-
minetest.register_alias("technic:uranium", "technic:uranium_lump")
98

109
minetest.register_craftitem(":technic:uranium_ingot", {
1110
description = S("Uranium Ingot"),
1211
inventory_image = "technic_uranium_ingot.png",
13-
groups = {uranium_ingot=1},
12+
groups = {uranium_ingot = 1},
1413
})
1514

1615
minetest.register_craftitem(":technic:chromium_lump", {
@@ -48,14 +47,6 @@ minetest.register_craftitem(":technic:sulfur_lump", {
4847
inventory_image = "technic_sulfur_lump.png",
4948
})
5049

51-
minetest.register_alias("technic:wrought_iron_ingot", "default:steel_ingot")
52-
53-
minetest.override_item("default:steel_ingot", {
54-
description = S("Wrought Iron Ingot"),
55-
-- make the color of the ingot a bit darker to separate it better from tin
56-
inventory_image = "technic_wrought_iron_ingot.png^[multiply:#bbbbbbff",
57-
})
58-
5950
minetest.register_craftitem(":technic:cast_iron_ingot", {
6051
description = S("Cast Iron Ingot"),
6152
inventory_image = "technic_cast_iron_ingot.png",
@@ -71,7 +62,21 @@ minetest.register_craftitem(":technic:stainless_steel_ingot", {
7162
inventory_image = "technic_stainless_steel_ingot.png",
7263
})
7364

74-
local function register_block(block, ingot)
65+
local blocks = {
66+
"uranium",
67+
"chromium",
68+
"zinc",
69+
"lead",
70+
"cast_iron",
71+
"carbon_steel",
72+
"stainless_steel",
73+
"sulfur",
74+
}
75+
76+
for _, name in pairs(blocks) do
77+
local block = "technic:"..name.."_block"
78+
local ingot = "technic:"..name.."_ingot"
79+
7580
minetest.register_craft({
7681
output = block,
7782
recipe = {
@@ -83,112 +88,66 @@ local function register_block(block, ingot)
8388

8489
minetest.register_craft({
8590
output = ingot.." 9",
86-
recipe = {
87-
{block}
88-
}
91+
recipe = {{block}}
8992
})
9093
end
9194

92-
register_block("technic:uranium_block", "technic:uranium_ingot")
93-
register_block("technic:chromium_block", "technic:chromium_ingot")
94-
register_block("technic:zinc_block", "technic:zinc_ingot")
95-
register_block("technic:lead_block", "technic:lead_ingot")
96-
register_block("technic:cast_iron_block", "technic:cast_iron_ingot")
97-
register_block("technic:carbon_steel_block", "technic:carbon_steel_ingot")
98-
register_block("technic:stainless_steel_block", "technic:stainless_steel_ingot")
99-
register_block("technic:sulfur_block", "technic:sulfur_lump")
100-
10195
minetest.register_craft({
102-
type = 'cooking',
96+
type = "cooking",
10397
recipe = "technic:zinc_lump",
10498
output = "technic:zinc_ingot",
10599
})
106100

107101
minetest.register_craft({
108-
type = 'cooking',
102+
type = "cooking",
109103
recipe = "technic:chromium_lump",
110104
output = "technic:chromium_ingot",
111105
})
112106

113107
minetest.register_craft({
114-
type = 'cooking',
108+
type = "cooking",
115109
recipe = "technic:uranium_lump",
116110
output = "technic:uranium_ingot",
117111
})
118112

119113
minetest.register_craft({
120-
type = 'cooking',
114+
type = "cooking",
121115
recipe = "technic:lead_lump",
122116
output = "technic:lead_ingot",
123117
})
124118

125-
126119
minetest.register_craft({
127-
type = 'cooking',
128-
recipe = minetest.registered_aliases["technic:wrought_iron_ingot"],
120+
type = "cooking",
121+
recipe = "default:steel_ingot",
129122
output = "technic:cast_iron_ingot",
130123
})
131124

132125
minetest.register_craft({
133-
type = 'cooking',
126+
type = "cooking",
134127
recipe = "technic:cast_iron_ingot",
135128
cooktime = 2,
136129
output = "technic:wrought_iron_ingot",
137130
})
138131

139132
minetest.register_craft({
140-
type = 'cooking',
133+
type = "cooking",
141134
recipe = "technic:carbon_steel_ingot",
142135
cooktime = 2,
143136
output = "technic:wrought_iron_ingot",
144137
})
145138

146-
local function for_each_registered_item(action)
147-
local already_reg = {}
148-
for k, _ in pairs(minetest.registered_items) do
149-
table.insert(already_reg, k)
150-
end
151-
local really_register_craftitem = minetest.register_craftitem
152-
minetest.register_craftitem = function(name, def)
153-
really_register_craftitem(name, def)
154-
action(string.gsub(name, "^:", ""))
155-
end
156-
local really_register_tool = minetest.register_tool
157-
minetest.register_tool = function(name, def)
158-
really_register_tool(name, def)
159-
action(string.gsub(name, "^:", ""))
160-
end
161-
local really_register_node = minetest.register_node
162-
minetest.register_node = function(name, def)
163-
really_register_node(name, def)
164-
action(string.gsub(name, "^:", ""))
165-
end
166-
for _, name in ipairs(already_reg) do
167-
action(name)
168-
end
169-
end
170-
171-
local steel_to_iron = {}
172-
for _, i in ipairs({
173-
"default:axe_steel",
174-
"default:pick_steel",
175-
"default:shovel_steel",
176-
"default:sword_steel",
177-
"doors:door_steel",
178-
"farming:hoe_steel",
179-
"glooptest:hammer_steel",
180-
"glooptest:handsaw_steel",
181-
"glooptest:reinforced_crystal_glass",
182-
"mesecons_doors:op_door_steel",
183-
"mesecons_doors:sig_door_steel",
184-
"vessels:steel_bottle",
185-
}) do
186-
steel_to_iron[i] = true
187-
end
139+
minetest.register_craft({
140+
output = "technic:marble_bricks 4",
141+
recipe = {
142+
{"technic:marble","technic:marble"},
143+
{"technic:marble","technic:marble"}
144+
}
145+
})
188146

189-
for_each_registered_item(function(item_name)
190-
local item_def = minetest.registered_items[item_name]
191-
if steel_to_iron[item_name] and string.find(item_def.description, "Steel") then
192-
minetest.override_item(item_name, { description = string.gsub(item_def.description, "Steel", S("Iron")) })
193-
end
194-
end)
147+
minetest.register_craft({
148+
output = "technic:granite_bricks 4",
149+
recipe = {
150+
{"technic:granite","technic:granite"},
151+
{"technic:granite","technic:granite"}
152+
}
153+
})

technic_worldgen/init.lua

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
local modpath = minetest.get_modpath("technic_worldgen")
23

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

1315
-- Rubber trees, moretrees also supplies these
1416
if not minetest.get_modpath("moretrees") then
1517
dofile(modpath.."/rubber.lua")
1618
else
17-
-- older versions of technic provided rubber trees regardless
19+
-- Older versions of technic provided rubber trees regardless
1820
minetest.register_alias("technic:rubber_sapling", "moretrees:rubber_tree_sapling")
1921
minetest.register_alias("technic:rubber_tree_empty", "moretrees:rubber_tree_trunk_empty")
2022
end
@@ -24,3 +26,9 @@ if minetest.get_modpath("mg") then
2426
dofile(modpath.."/mg.lua")
2527
end
2628

29+
minetest.register_alias("technic:wrought_iron_ingot", "default:steel_ingot")
30+
minetest.register_alias("technic:uranium", "technic:uranium_lump")
31+
minetest.register_alias("technic:wrought_iron_block", "default:steelblock")
32+
minetest.register_alias("technic:diamond_block", "default:diamondblock")
33+
minetest.register_alias("technic:diamond", "default:diamond")
34+
minetest.register_alias("technic:mineral_diamond", "default:stone_with_diamond")

technic_worldgen/mod.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
name = technic_worldgen
22
depends = default
3-
optional_depends = intllib, mg, doors, farming, glooptest, mesecons_doors, vessels
3+
optional_depends = intllib, mg

0 commit comments

Comments
 (0)