sorcery  Diff

Differences From Artifact [32259e26c1]:

To Artifact [f9db217ceb]:

  • File metal.lua — part of check-in [3f6a913e4e] at 2020-09-29 12:40:28 on branch trunk — * remove former hacky registration system, replace with consistent and flexible API; rewrite metal/gem generation to take advantage of this new API; tweaks to init system to enable world-local tweaks to lore and sorcery behavior * initial documentation commit * initial steps towards calendar - add default date format, astrolabe; prepare infra for division/melding/transmutation spells, various tweaks and fixes (user: lexi, size: 6107) [annotate] [blame] [check-ins using]

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
..
37
38
39
40
41
42
43
44

45
46
47
48
49
50
51
..
76
77
78
79
80
81
82
83
84
85
86
87
88
89







90
91
92
93
94
95
96
...
140
141
142
143
144
145
146







147
148
149
150
151
152
153
...
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
	name = "sorcery:delete_duranium_ore_again";
	nodenames = {'sorcery:stone_with_duranium'};
	action = function(pos,node)
		minetest.set_node(pos, {name = 'default:stone'})
	end
}

sorcery.data.alloys = {}
sorcery.data.kilnrecs = {}
sorcery.data.metallookup = {
	-- compat bullshit
	['moreores:silver_ingot'] = {
		id = 'silver'; data = sorcery.data.metals.silver;
		value = fragments_per_ingot;
	};
	['moreores:silver_block'] = {
................................................................................
	['morelights_vintage:brass_block'] = {
		id = 'brass'; data = sorcery.data.metals.brass;
		value = fragments_per_ingot * 9;
	};
}

local tools, armors = sorcery.matreg.tools, sorcery.matreg.armors
for name, metal in pairs(sorcery.data.metals) do

	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
	metal.parts = {
		ingot = ingot;
................................................................................
		id = name; data = metal;
		value = fragments_per_ingot * 9;
	}
	sorcery.data.metallookup[fragment] = {
		id = name; data = metal;
		value = 1;
	}
	sorcery.data.metallookup[screw] = {
		id = name; data = metal;
		value = 0; -- prevent use in smelting
	}
	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();







	})
	minetest.register_craftitem(powder, {
		description = sorcery.lib.str.capitalize(name) .. ' Powder';
		inventory_image = 'sorcery_' .. name .. '_powder.png';
	})
	if metal.dye then
		minetest.register_craft {
................................................................................
			armor_weight = metal.armor_weight;
			armor_protection = metal.armor_protection;
		}
	end
	minetest.register_craftitem(fragment, {
		inventory_image = 'sorcery_' .. name .. '_fragment.png';
		description = sorcery.lib.str.capitalize(name) .. ' Fragment';







	})
	minetest.register_craft {
		type = 'cooking';
		recipe = powder;
		cooktime = (metal.cooktime or 4) * 0.25;
		output = fragment;
	}
................................................................................
		minetest.register_craft {
			type = 'fuel';
			recipe = powder;
			burntime = metal.fuel;
		}
	end
	if metal.mix then
		sorcery.data.register.alloy(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.data.infusion_leftovers[m] then
					repl[#repl+1] = {m, sorcery.data.infusion_leftovers[m]}
				end
			end
		end

		minetest.register_craft {
			type = 'shapeless';
			output = powder .. ' ' .. tostring(#powders);
			recipe = powders;
			replacements = repl;
		};
	end
end







|
|







 







|
>







 







<
<
<
<



>
>
>
>
>
>
>







 







>
>
>
>
>
>
>







 







|













|
|











|
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
..
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
..
77
78
79
80
81
82
83




84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
...
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
...
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
	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'] = {
................................................................................
	['morelights_vintage:brass_block'] = {
		id = 'brass'; data = sorcery.data.metals.brass;
		value = fragments_per_ingot * 9;
	};
}

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
	metal.parts = {
		ingot = ingot;
................................................................................
		id = name; data = metal;
		value = fragments_per_ingot * 9;
	}
	sorcery.data.metallookup[fragment] = {
		id = name; data = metal;
		value = 1;
	}




	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();
		_sorcery = {
			material = {
				id = name, data = metal;
				grindcost = 2, grindvalue = 1;
				value = 0.5;
			};
		};
	})
	minetest.register_craftitem(powder, {
		description = sorcery.lib.str.capitalize(name) .. ' Powder';
		inventory_image = 'sorcery_' .. name .. '_powder.png';
	})
	if metal.dye then
		minetest.register_craft {
................................................................................
			armor_weight = metal.armor_weight;
			armor_protection = metal.armor_protection;
		}
	end
	minetest.register_craftitem(fragment, {
		inventory_image = 'sorcery_' .. name .. '_fragment.png';
		description = sorcery.lib.str.capitalize(name) .. ' Fragment';
		_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 = '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(#powders);
			recipe = powders;
			replacements = repl;
		};
	end
end)