Differences From
Artifact [a738b55bd0]:
1 +local cast_sparkle = function(ctx,color,strength,duration)
2 + minetest.add_particlespawner {
3 + amount = 70 * strength;
4 + time = duration or 1.5;
5 + attached = ctx.caster;
6 + texture = sorcery.lib.image('sorcery_spark.png'):multiply(color):render();
7 + minpos = { x = -0.1, z = 0.5, y = 1.2};
8 + maxpos = { x = 0.1, z = 0.3, y = 1.6};
9 + minvel = { x = -0.5, z = -0.5, y = -0.5};
10 + maxvel = { x = 0.5, z = 0.5, y = 0.5};
11 + minacc = { x = 0.0, z = 0.0, y = 0.5};
12 + maxacc = { x = 0.0, z = 0.0, y = 0.5};
13 + minsize = 0.4, maxsize = 0.8;
14 + minexptime = 1, maxexptime = 1;
15 + glow = 14;
16 + animation = {
17 + type = 'vertical_frames';
18 + aspect_w = 16;
19 + aspect_h = 16;
20 + length = 1.1;
21 + };
22 + }
23 +end
1 24 local enchantment_sparkle = function(ctx,color)
25 + local minvel, maxvel
26 + if minetest.get_node(vector.add(ctx.target.under,{y=1,z=0,x=0})).name == 'air' then
27 + minvel = {x=0,z=0,y= 0.3} maxvel = {x=0,z=0,y= 1.5};
28 + else
29 + local dir = vector.subtract(ctx.target.under,ctx.target.above)
30 + minvel = vector.multiply(dir, 0.3)
31 + maxvel = vector.multiply(dir, 1.2)
32 + end
2 33 return minetest.add_particlespawner {
3 34 amount = 50;
4 35 time = 0.5;
5 36 minpos = vector.subtract(ctx.target.under, 0.5);
6 37 maxpos = vector.add(ctx.target.under, 0.5);
7 - minvel = {x=0,z=0,y= 0.3}, maxvel = {x=0,z=0,y= 1.5};
8 - minacc = {x=-0.2,z=-0.2,y=-0.1}, maxacc = {x=0.2,z=0.2,y=-0.2};
38 + minvel = minvel, maxvel = maxvel;
9 39 minexptime = 1, maxexptime = 2;
10 40 minsize = 0.5, maxsize = 2;
11 41 texture = sorcery.lib.image('sorcery_spark.png'):multiply(color):render();
12 42 animation = {
13 43 type = 'vertical_frames';
14 44 aspect_w = 16, aspect_h = 16;
15 45 length = 2;
................................................................................
232 262 affinity = {'apple','silent'};
233 263 uses = 128;
234 264 desc = 'Reveal the strength and affinities of the local leyline';
235 265 cast = function(ctx)
236 266 local color = ctx.base.gem == 'sapphire';
237 267 local duration = (ctx.base.gem == 'amethyst' and 4) or 2;
238 268 local ley = sorcery.ley.estimate(ctx.caster:get_pos())
239 - local emit = function(color,strength)
240 - minetest.add_particlespawner {
241 - amount = 70 * strength;
242 - time = duration * strength;
243 - attached = ctx.caster;
244 - texture = sorcery.lib.image('sorcery_spark.png'):
245 - multiply(color:brighten(1.3)):render();
246 - minpos = { x = -0.1, z = 0.5, y = 1.2};
247 - maxpos = { x = 0.1, z = 0.3, y = 1.6};
248 - minvel = { x = -0.5, z = -0.5, y = -0.5};
249 - maxvel = { x = 0.5, z = 0.5, y = 0.5};
250 - minacc = { x = 0.0, z = 0.0, y = 0.5};
251 - maxacc = { x = 0.0, z = 0.0, y = 0.5};
252 - minsize = 0.4, maxsize = 0.8;
253 - minexptime = 1, maxexptime = 1;
254 - glow = 14;
255 - animation = {
256 - type = 'vertical_frames';
257 - aspect_w = 16;
258 - aspect_h = 16;
259 - length = 1.1;
260 - };
261 - }
262 - end
263 269
264 270 local strength = ley.force
265 271 if color then
266 272 strength = strength / #ley.aff
267 273 for _,a in pairs(ley.aff) do
268 - emit(sorcery.lib.color(sorcery.data.affinities[a].color), strength)
274 + cast_sparkle(ctx,sorcery.lib.color(sorcery.data.affinities[a].color):brighten(1.3), strength, duration * strength)
269 275 end
270 276 else
271 - emit(sorcery.lib.color(250,255,185), strength)
277 + cast_sparkle(ctx,sorcery.lib.color(250,255,185), strength, duration*strength)
272 278 end
273 279
274 280 end;
275 281 };
276 282 dowse = {
277 283 name = 'dowsing';
278 284 leytype = 'cognic';
................................................................................
308 314 attune = {
309 315 name = 'attunement';
310 316 uses = 38;
311 317 color = {255,65,207};
312 318 leytype = 'syncretic';
313 319 affinity = {'pine','verdant','dark'};
314 320 desc = 'Establish a connection between mystic mechanisms, like connecting two sides of a portal or impressing targets onto a dowsing wand in an enchanter';
321 + cast = function(ctx)
322 + if not (ctx.target and ctx.target.type == 'node') then
323 + ctx.meta:set_string('source','')
324 + cast_sparkle(ctx, sorcery.lib.color(234,45,100), 0.3)
325 + return true
326 + end
327 + local n = minetest.registered_nodes[minetest.get_node(ctx.target.under).name]
328 + if not (n and n._sorcery and n._sorcery.attune) then
329 + return false end -- just in case anyone casts on an undefined node
330 + local m = sorcery.lib.marshal
331 + local encpos, decpos = m.transcoder {
332 + x = m.t.s32, y = m.t.s32, z = m.t.s32;
333 + id = m.t.str;
334 + }
335 + local props = n._sorcery.attune
336 +
337 + local rec = ctx.meta:get_string('source')
338 + local src
339 + if rec then
340 + local data = decpos(sorcery.lib.str.meta_dearmor(rec,true))
341 + local srcpos = {x=data.x,y=data.y,z=data.z}
342 + local srcnode = minetest.get_node(srcpos)
343 + local srcdef = minetest.registered_nodes[srcnode.name]
344 + if srcdef and srcdef._sorcery and srcdef._sorcery.attune then
345 + if sorcery.attunement.nodeid(srcpos) == data.id then
346 + -- check for ink
347 + src = {
348 + pos = srcpos;
349 + props = srcdef._sorcery.attune;
350 + }
351 + end
352 + end
353 + end
354 +
355 + local color
356 + if src and src.props.source and
357 + src.props.class == props.accepts and props.target and
358 + (not vector.equals(src.pos, ctx.target.under)) then
359 + sorcery.attunement.pair(src.props.reciprocal or true, src.pos, ctx.target.under)
360 + ctx.meta:set_string('source','')
361 + color = sorcery.lib.color(255,130,75)
362 + elseif props.source then
363 + ctx.meta:set_string('source', sorcery.lib.str.meta_armor(encpos {
364 + x = ctx.target.under.x;
365 + y = ctx.target.under.y;
366 + z = ctx.target.under.z;
367 + id = sorcery.attunement.nodeid(ctx.target.under);
368 + },true))
369 + color = sorcery.lib.color(128,75,255)
370 + end
371 +
372 + if color then enchantment_sparkle(ctx,color)
373 + else return false end
374 + end;
315 375 };
316 376 meld = {
317 377 name = 'melding';
318 378 uses = 48;
319 379 leytype = 'syncretic';
320 380 color = {172,65,255};
321 381 affinity = {'apple','verdant'};
................................................................................
364 424 disjoin = {
365 425 name = 'disjunction';
366 426 uses = 32;
367 427 color = {17,6,212};
368 428 leytype = 'occlutic';
369 429 affinity = {'jungle','silent'};
370 430 desc = 'With an enchanter, disjoin the anchor holding a spell into an object so a new spell can instead be bound in';
431 + };
432 + divine = {
433 + name = 'divining';
434 + desc = 'Steal away the secrets of the cosmos';
435 + uses = 16;
436 + color= {97,97,255};
437 + sound = 'xdecor:enchanting';
438 + leytype = 'cognic';
439 + affinity = {'pine','shimmering','dark','verdant'};
440 + cast = function(ctx)
441 + local inks = {'black','red','white','violet','blue','green'}
442 + local getcolor = function(stack)
443 + if stack:is_empty() then return nil end
444 + if minetest.get_item_group(stack:get_name(), 'dye') == 0 then return nil end
445 + for _,ink in pairs(inks) do
446 + if minetest.get_item_group(stack:get_name(), 'color_' ..ink) ~= 0
447 + then print('found',ink,'ink') return ink end
448 + end
449 + end
450 + if not ctx.target or ctx.target.type ~= 'node' then return false end
451 + local tgt = minetest.get_node(ctx.target.under)
452 + if tgt.name == 'sorcery:enchanter' then
453 + local meta = minetest.get_meta(ctx.target.under)
454 + local inv = meta:get_inventory()
455 + if inv:get_stack('item',1):get_name() == 'default:paper'
456 + and inv:get_stack('item',1):get_count() == 1
457 + and not inv:is_empty('foci') then
458 + local ink1 = getcolor(inv:get_stack('foci',2))
459 + local ink2 = getcolor(inv:get_stack('foci',3))
460 + local restrict, kind, mod = {} do
461 + local ms = inv:get_stack('foci',1)
462 + if not ms:is_empty() then mod = ms:get_name() end
463 + end
464 + print(ink1,ink2,mod)
465 + if ink1 == 'black' and ink2 == 'black' then kind = 'craft'
466 + if mod then
467 + if mod == sorcery.data.metals.cobalt.parts.powder then
468 + restrict.group = 'sorcery_magitech'
469 + elseif mod == sorcery.data.metals.vidrium.parts.powder then
470 + restrict.group = 'sorcery_ley_device'
471 + elseif mod == sorcery.data.metals.aluminum.parts.powder then
472 + restrict.group = 'sorcery_metallurgy'
473 + elseif mod == sorcery.data.metals.lithium.parts.powder then
474 + restrict.group = 'sorcery_enchanting_lens'
475 + elseif mod == sorcery.data.metals.iridium.parts.powder then
476 + restrict.group = 'sorcery_worship'
477 + elseif mod == sorcery.data.metals.gold.parts.powder then
478 + restrict.group = 'sorcery_grease'
479 + elseif mod == sorcery.data.metals.silver.parts.powder then
480 + restrict.group = 'sorcery_oil'
481 + elseif mod == sorcery.data.metals.electrum.parts.powder then
482 + restrict.group = 'sorcery_extract'
483 + elseif mod == 'farming:sugar' then
484 + restrict.mod = 'farming'
485 + else return false end
486 + end
487 + elseif ink1 == 'black' and ink2 == 'white' then kind = 'infuse'
488 + if mod then
489 + if mod == sorcery.data.metals.gold.parts.powder then
490 + restrict.mod = 'sorcery_draught'
491 + elseif mod == sorcery.data.metals.cobalt.parts.powder then
492 + restrict.mod = 'sorcery_philter'
493 + elseif mod == sorcery.data.metals.lithium.parts.powder then
494 + restrict.mod = 'sorcery_elixirs'
495 + else return false end
496 + end
497 + elseif ink1 == 'blue' and ink2 == 'violet' then kind = 'enchant'
498 + if mod then
499 + if mod == sorcery.data.metals.cobalt.parts.powder then
500 + restrict.aff = 'praxic'
501 + elseif mod == sorcery.data.metals.tungsten.parts.powder then
502 + restrict.aff = 'counterpraxic'
503 + elseif mod == sorcery.data.metals.aluminum.parts.powder then
504 + restrict.aff = 'syncretic'
505 + elseif mod == sorcery.data.metals.lithium.parts.powder then
506 + -- restrict.aff = 'mandatic' -- no enchants yet, will cause infinite loop
507 + elseif mod == sorcery.data.metals.iridium.parts.powder then
508 + restrict.aff = 'entropic'
509 + elseif mod == sorcery.data.metals.gold.parts.powder then
510 + restrict.aff = 'cognic'
511 + elseif mod == sorcery.data.metals.silver.parts.powder then
512 + -- restrict.aff = 'occlutic'
513 + elseif mod == sorcery.data.metals.electrum.parts.powder then
514 + -- restrict.aff = 'imperic'
515 + else return false end
516 + end
517 + elseif ink1 == 'red' and ink2 == 'yellow' then kind = 'cook';
518 + -- elseif ink1 == 'red' and ink2 == 'orange' then kind = 'smelt';
519 + end
520 + print('result',kind,dump(restrict))
521 + if kind then
522 + print('found kind')
523 + local rec = ItemStack('sorcery:recipe')
524 + local m = rec:get_meta()
525 + if ctx.base.gem == 'diamond' then
526 + -- make recipe for thing in slot 1
527 + else
528 + sorcery.cookbook.setrecipe(rec,kind,nil,restrict)
529 + end
530 + inv:set_stack('item',1,rec)
531 + for i=1,inv:get_size('foci') do
532 + local f = inv:get_stack('foci',i)
533 + f:take_item(1)
534 + inv:set_stack('foci',i,f)
535 + end
536 + enchantment_sparkle(ctx,sorcery.lib.color(97,97,255))
537 + return
538 + end
539 + end
540 + end
541 + return false
542 + end;
371 543 };
372 544 luminate = {
373 545 name = 'lumination';
374 546 desc = 'Banish darkness all about you for a few moments';
375 547 uses = 40;
376 548 color = {244,255,157};
377 549 affinity = {'acacia','shimmering','blazing'};