sorcery  Diff

Differences From Artifact [9b1dfc7187]:

To Artifact [0d89fbd301]:


   448    448   			end
   449    449   			if not ctx.target or ctx.target.type ~= 'node' then return false end
   450    450   			local tgt = minetest.get_node(ctx.target.under)
   451    451   			if tgt.name == 'sorcery:enchanter' then
   452    452   				local meta = minetest.get_meta(ctx.target.under)
   453    453   				local inv = meta:get_inventory()
   454    454   				if inv:get_stack('item',1):get_name() == 'default:paper'
   455         -					and inv:get_stack('item',1):get_count() == 1
          455  +					-- and inv:get_stack('item',1):get_count() == 1
   456    456   					and not inv:is_empty('foci') then
   457    457   				   local ink1 = getcolor(inv:get_stack('foci',2))
   458    458   				   local ink2 = getcolor(inv:get_stack('foci',3))
   459    459   				   local restrict, kind, mod = {} do
   460    460   					   local ms = inv:get_stack('foci',1)
   461    461   					   if not ms:is_empty() then mod = ms:get_name() end
   462    462   				   end
................................................................................
   522    522   					   local rec = ItemStack('sorcery:recipe')
   523    523   					   local m = rec:get_meta()
   524    524   					   if ctx.base.gem == 'diamond' then
   525    525   						   -- make recipe for thing in slot 1
   526    526   					   else
   527    527   						   sorcery.cookbook.setrecipe(rec,kind,nil,restrict)
   528    528   					   end
   529         -					   inv:set_stack('item',1,rec)
          529  +					   local old = inv:get_stack('item',1)
          530  +					   -- TODO: detect hopper underneath and place
          531  +					   -- recipe into it instead of item slot
          532  +					   if old:get_count() == 1 then
          533  +						   inv:set_stack('item',1,rec)
          534  +					   else
          535  +						   old:take_item(1)
          536  +						   inv:set_stack('item',1,old)
          537  +						   minetest.add_item(ctx.target.above,rec)
          538  +					   end
   530    539   					   for i=1,inv:get_size('foci') do
   531    540   						   local f = inv:get_stack('foci',i)
   532    541   						   f:take_item(1)
   533    542   						   inv:set_stack('foci',i,f)
   534    543   					   end
   535    544   					   enchantment_sparkle(ctx,sorcery.lib.color(97,97,255))
   536    545   					   return