sorcery  Check-in [669078947d]

Overview
Comment:add lathe recipes, bugfixes
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 669078947dc575378783161b2bc3da75b0ced1bd66a9152bf6bbea9559437c03
User & Date: lexi on 2021-07-08 23:14:33
Other Links: manifest | tags
Context
2021-07-10
00:43
remove unnecessary neighbor restriction check-in: ced73b0ebe user: lexi tags: trunk
2021-07-08
23:14
add lathe recipes, bugfixes check-in: 669078947d user: lexi tags: trunk
21:52
add tree lathe recipes check-in: 56a2b90c1b user: lexi tags: trunk
Changes

Modified cookbook.lua from [1bf06d7139] to [bc084489e5].

42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
...
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
...
193
194
195
196
197
198
199

























200
201
202
203
204
205
206
...
327
328
329
330
331
332
333






















































334
335
336
337
338
339
340
...
504
505
506
507
508
509
510
511





512
513
514
515
516
517
518

local slot3x3 = {
	{0,0}, {1,0}, {2,0};
	{0,1}, {1,1}, {2,1};
	{0,2}, {1,2}, {2,2};
}
local props_builtin = function(item)
	local props = minetest.registered_items[item]._sorcery
	if props and props.recipe then
		return props.recipe
	end
	return {}
end
local modofname = function(id)
	local item = minetest.registered_nodes[id]
................................................................................
		return i
	end
	return i
end
local function desc_builtin(i)
	local desc
	i, desc = group_eval(i)
	-- print('describing ',i,dump(minetest.registered_items[i]))
	local s = ItemStack(i)
	if not minetest.registered_items[s:get_name()] then
		minetest.log('WARNING: unknown item in recipe ' .. i)
		return 'Unknown Item'
	end
	if not desc then desc = minetest.registered_items[s:get_name()].description end
	if not desc then return 'Peculiar Item' end

	local eol = string.find(desc,'\n')
	if eol then desc = string.sub(desc,1,eol-1) end
................................................................................
			for k,v in pairs(minetest.registered_items) do
				if sorcery.itemclass.get(k, 'grindable') then
					cache.grindables[#cache.grindables+1] = k
				end
			end
		end
	end;

























}
sorcery.cookbook.classes = {
	craft = {
		name = 'Crafting Guide';
		node = 'xdecor:workbench';
		booksuf = 'Codex';
		w = 3, h = 3;
................................................................................
							return {v, 'sorcery:mill_grindhead_' .. metal}
						end
					end
					return {v,''} -- !!
				end
			end
		end;






















































	};
	enchant = {
		name = 'Enchantment Matrix';
		node = 'sorcery:enchanter';
		booksuf = 'Grimoire';
		drawslots = false;
		chance = 4;
................................................................................
		img and 'image' or 'item_image',
			k.w+1.1, k.h/2 - 0.5, minetest.formspec_escape(img or result),
			k.w+1.1, k.h/2 - 0.5, minetest.formspec_escape(ot))
end;

local retrieve_recipe = function(kind,out,notes_right)
	local rec = recipe_kinds[kind]
	local ing = rec.find(out)





	return render_recipe(kind,ing,out,notes_right), rec.w, rec.h
end

sorcery.cookbook.setrecipe = function(stack,k,r,restrict)
	local meta = stack:get_meta()
	if not r then r,k = sorcery.cookbook.pickrecipe(k,restrict) end
	if not r then return false end







|







 







<


|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|
>
>
>
>
>







42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
...
149
150
151
152
153
154
155

156
157
158
159
160
161
162
163
164
165
...
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
...
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
...
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601

local slot3x3 = {
	{0,0}, {1,0}, {2,0};
	{0,1}, {1,1}, {2,1};
	{0,2}, {1,2}, {2,2};
}
local props_builtin = function(item)
	local props = minetest.registered_items[ItemStack(item):get_name()]._sorcery
	if props and props.recipe then
		return props.recipe
	end
	return {}
end
local modofname = function(id)
	local item = minetest.registered_nodes[id]
................................................................................
		return i
	end
	return i
end
local function desc_builtin(i)
	local desc
	i, desc = group_eval(i)

	local s = ItemStack(i)
	if not minetest.registered_items[s:get_name()] then
		log.warn('unknown item in recipe',i)
		return 'Unknown Item'
	end
	if not desc then desc = minetest.registered_items[s:get_name()].description end
	if not desc then return 'Peculiar Item' end

	local eol = string.find(desc,'\n')
	if eol then desc = string.sub(desc,1,eol-1) end
................................................................................
			for k,v in pairs(minetest.registered_items) do
				if sorcery.itemclass.get(k, 'grindable') then
					cache.grindables[#cache.grindables+1] = k
				end
			end
		end
	end;

	populate_lathe = function(cache)
		if cache.lathe then return end
		cache.lathe = { tools = {} }
		for k in pairs(sorcery.lathe.techs) do cache.lathe.tools[k] = {} end

		for id, item in pairs(minetest.registered_tools) do
			for group, tech in pairs(sorcery.lathe.tools) do
				if minetest.get_item_group(id, group) ~= 0 then
					local tt = cache.lathe.tools[tech]
					local mat = sorcery.itemclass.get(id, 'material')
					tt[#tt+1] = {
						id = id;
						ptr = item;
						level = mat and mat.data and (mat.data.maxlevel or mat.data.level) or nil;
					}
				end
			end
		end
		for _, tech in pairs(sorcery.lathe.tools) do
			table.sort(cache.lathe.tools[tech], function(a,b)
				return (a.level or 0) < (b.level or 0)
			end)
		end
	end;
}
sorcery.cookbook.classes = {
	craft = {
		name = 'Crafting Guide';
		node = 'xdecor:workbench';
		booksuf = 'Codex';
		w = 3, h = 3;
................................................................................
							return {v, 'sorcery:mill_grindhead_' .. metal}
						end
					end
					return {v,''} -- !!
				end
			end
		end;
	};
	lathe = {
		name = 'Lathe';
		chance = 1;
		node = 'sorcery:lathe';
		booksuf = 'Compendium';
		w = 2, h = 1;
		slots = { {1,0}, {0,0} };
		apply_exclusions = true;
		props = props_builtin;
		find = function(out)
			cache:populate_lathe()
			local mat = sorcery.itemclass.get(out, 'material')
			local level = 0
			if mat and mat.data and mat.data.level then
				level = mat.data.level
			end
			for input,tqs in pairs(sorcery.lathe.recipes) do
				for tech, defs in pairs(tqs) do
					for _, def in pairs(defs) do
						if ItemStack(def.output):get_name() == out then
							local tool
							if level > 0 then
								for _,t in pairs(cache.lathe.tools[tech]) do
									if (t.level or 0) >= level then
										tool = t.id
										break
									end
								end
							else
								tool = cache.lathe.tools[tech][1].id
							end
							if def.mass then input = input .. ' ' .. tostring(def.mass) end
							local rec = {input, tool or ''}
							return rec, {count = ItemStack(def.output):get_count()}
						end
					end
				end
			end
		end;
		pick = function(restrict)
			local p = {}
			for input,tqs in pairs(sorcery.lathe.recipes) do
				for tech, defs in pairs(tqs) do
					for _, def in pairs(defs) do
						local nm = ItemStack(def.output):get_name()
						if item_restrict_eval(nm, restrict) then
							p[#p+1] = nm
						end
					end
				end
			end
			return select(2, sorcery.lib.tbl.pick(p))
		end;
	};
	enchant = {
		name = 'Enchantment Matrix';
		node = 'sorcery:enchanter';
		booksuf = 'Grimoire';
		drawslots = false;
		chance = 4;
................................................................................
		img and 'image' or 'item_image',
			k.w+1.1, k.h/2 - 0.5, minetest.formspec_escape(img or result),
			k.w+1.1, k.h/2 - 0.5, minetest.formspec_escape(ot))
end;

local retrieve_recipe = function(kind,out,notes_right)
	local rec = recipe_kinds[kind]
	local ing, props = rec.find(out)
	if props then
		if props.count then
			out = out .. ' ' .. tostring(props.count)
		end
	end
	return render_recipe(kind,ing,out,notes_right), rec.w, rec.h
end

sorcery.cookbook.setrecipe = function(stack,k,r,restrict)
	local meta = stack:get_meta()
	if not r then r,k = sorcery.cookbook.pickrecipe(k,restrict) end
	if not r then return false end

Modified data/metals.lua from [eba257a7d6] to [36b84b05c4].

231
232
233
234
235
236
237

238
239
240
241
242
243
244
		rarity = 13;
		hardness = 2;
		fuel = 80;
		depth = 670;
		level = 1;
		no_tools = true;
		no_armor = true;

	};
	vidrium = {
		tone = {119,185,221}, alpha = 140;
		artificial = true;
		dye = 'cyan';
		hardness = 1;
		durability = 300;







>







231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
		rarity = 13;
		hardness = 2;
		fuel = 80;
		depth = 670;
		level = 1;
		no_tools = true;
		no_armor = true;
		no_craftables = true;
	};
	vidrium = {
		tone = {119,185,221}, alpha = 140;
		artificial = true;
		dye = 'cyan';
		hardness = 1;
		durability = 300;

Modified metal.lua from [69d743e332] to [f2df9bf8e4].

80
81
82
83
84
85
86









87
88
89
90
91
92
93
94
95
96
97
98
99












100
101
102
103
104
105
106
107

108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
		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();
		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;
			};
		};
	})












	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;

				grindvalue = (3*4) / 2;
				value = 4 * (2/3);
			};
		};
	})

	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)

	sorcery.lathe.register {
		input = ingot, mass = 2;
		output = {name = disc, count = 3};
		tech = 'cut', cost = 5;
	}
	sorcery.lathe.register {
		input = block;







>
>
>
>
>
>
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>








>
|





<
<
<
<
<
<
<
<
<
<
<







80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135











136
137
138
139
140
141
142
		id = name; data = metal;
		value = fragments_per_ingot * 9;
	}
	sorcery.data.metallookup[fragment] = {
		id = name; data = metal;
		value = 1;
	}
	sorcery.data.metallookup[disc] = {
		id = name; data = metal;
		value = 8/3;
	}
	if not metal.no_craftables then
		sorcery.data.metallookup[screw] = {
			id = name; data = metal;
			value = 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, mass = 2;
		output = {name = disc, count = 3};
		tech = 'cut', cost = 5;
	}
	sorcery.lathe.register {
		input = block;