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
|