Index: coins.lua ================================================================== --- coins.lua +++ coins.lua @@ -66,11 +66,12 @@ local metalname, gemname local coincount if not inv:is_empty('ingot') then local id = slot_ingot:get_name() for name,metal in pairs(sorcery.data.metals) do - if id == metal.parts.ingot then + if id == metal.parts.ingot or + id == minetest.registered_aliases[metal.parts.ingot] then metalname = name coincount = slot_ingot:get_count() goto foundmetal end end @@ -148,16 +149,20 @@ end; allow_metadata_inventory_put = function(pos,list,idx,stack,user) local id = stack:get_name() if list == 'ingot' then for name,metal in pairs(sorcery.data.metals) do - if id == metal.parts.ingot then goto okay end + if id == metal.parts.ingot or + id == minetest.registered_aliases[metal.parts.ingot] + then goto okay end end elseif list == 'gem' then for name,gem in pairs(sorcery.data.gems) do if gem.foreign then - if id == gem.foreign then goto okay end + if id == gem.foreign or + id == minetest.registered_aliases[gem.foreign] + then goto okay end else if id == 'sorcery:gem_' .. name then goto okay end end end end @@ -181,11 +186,24 @@ if list == 'output' then local items_used = math.floor(stack:get_count() / coins_per_ingot) local inv = meta:get_inventory() local reduce_slot = function(slot) local i = inv:get_stack(slot,1) + local s = i:get_name() i:take_item(items_used) inv:set_stack(slot,1,i) + if slot == 'gem' then + for k,v in pairs(sorcery.data.gems) do + if v.parts.item == s then + local repl = ItemStack { + name = v.parts.shard; + count = items_used; + } + u.node.insert(repl, 'gem', pos, user, inv) + break + end + end + end end reduce_slot('ingot') if not inv:is_empty('gem') then reduce_slot('gem') end minetest.sound_play('sorcery_coins', { pos = pos, gain = 0.7 }) end Index: lib/node.lua ================================================================== --- lib/node.lua +++ lib/node.lua @@ -132,10 +132,26 @@ if not sorcery.lib.node.is_air(pos) then return false end local ents = minetest.get_objects_inside_radius(pos,0.5) if #ents > 0 then return false end return true end; + + insert = function(item, slot, npos, user, inv) + inv = inv or minetest.get_meta(npos):get_inventory() + if inv:room_for_item(slot,item) then + inv:add_item(slot,item) + else repeat + if user then + local ui = user:get_inventory() + if ui:room_for_item('main', item) then + ui:add_item('main', item) + break + end + end + minetest.add_item(npos, item) + until true end + end; tree_is_live = function(pos, checklight) -- VERY EXPENSIVE FUNCTION -- this is going to require some explanation. -- -- for various purposes, we want to be able to tell the difference between