@@ -131,17 +131,22 @@ for i=1,inv:get_size('input') do local m = inv:get_stack('input',i) if m:is_empty() then goto skip end local l = sorcery.data.metallookup[m:get_name()] + if not l then + local p = sorcery.lib.tbl.walk(m:get_definition()._sorcery,{'material'}) + if p.metal then l = p end + end if not l then return false end mix[l.id] = (mix[l.id] or 0) + l.value count = count + l.value ::skip::end + count = math.floor(count) -- everything is metal, we've finished summing it up. -- let's see if the assembled items match the ratio -- specified in any of the smelting recipes. local matches = 0 - for _,rec in pairs(sorcery.data.alloys) do + for _,rec in pairs(sorcery.register.alloys.db) do local fac = nil local meltpoint = 1 if rec.metals == nil then goto skip_recipe end for metal, ratio in pairs(rec.metals) do @@ -211,18 +216,34 @@ s:take_item(1) inv:set_stack('input',i,s) ::skip::end local outstack - if count % fragments_per_ingot == 0 then - outstack = ItemStack { - name = sorcery.data.metals[recipe.output].ingot or 'sorcery:' .. recipe.output .. '_ingot'; - count = count / fragments_per_ingot; - } + if type(output) == 'table' then + for v,item in pairs(output) do + if count % v == 0 then + outstack = ItemStack { + name = item; + count = count / v; + } + end + end else - outstack = ItemStack { - name = 'sorcery:fragment_' .. recipe.output; - count = count; - } + if count % (fragments_per_ingot * 9) == 0 then + outstack = ItemStack { + name = sorcery.data.metals[recipe.output].parts.block; + count = count / (fragments_per_ingot*9); + } + elseif count % fragments_per_ingot == 0 then + outstack = ItemStack { + name = sorcery.data.metals[recipe.output].parts.ingot; + count = count / fragments_per_ingot; + } + else + outstack = ItemStack { + name = 'sorcery:fragment_' .. recipe.output; + count = count; + } + end end local leftover = inv:add_item('output',outstack) if not leftover:is_empty() then @@ -305,8 +326,9 @@ drop = id; groups = { cracky = (state == 'open' and 2) or nil; sorcery_metallurgy = 1; + not_in_creative_inventory = (state == open) and nil or 1; }; sunlight_propagates = true; paramtype1 = 'light'; paramtype2 = 'facedir'; @@ -387,8 +409,9 @@ after_dig_node = sorcery.lib.node.purge_container; groups = { cracky = (active and 2) or nil; sorcery_metallurgy = 1; + not_in_creative_inventory = active and 1 or nil; }; paramtype2 = 'facedir'; light_source = (active and 9) or 0; on_construct = function(pos)