Christopher Head
2019-01-26 4f78a69ffc714886c9d6e812f78d543bb33fe674
technic/machines/register/common.lua
@@ -66,14 +66,14 @@
      output_name = "dst"
   end
   
   local meta = minetest.get_meta(pos)
   local meta = minetest.get_meta(pos)
   local inv = meta:get_inventory()
   local i = 0
   for _, stack in ipairs(inv:get_list(output_name)) do
      i = i + 1
      if stack then
         local item0 = stack:to_table()
         if item0 then
         if item0 then
            item0["count"] = "1"
            technic.tube_inject_item(pos, pos, vector.new(x_velocity, 0, z_velocity), item0)
            stack:take_item(1)
@@ -124,7 +124,7 @@
   if node.param2 == 0 then pos1.x = pos1.x + 1  x_velocity =  1 end
   local output_tube_connected = false
   local node1 = minetest.get_node(pos1)
   local node1 = minetest.get_node(pos1)
   if minetest.get_item_group(node1.name, "tubedevice") > 0 then
      output_tube_connected = true
   end
@@ -147,14 +147,29 @@
            S("Machine cannot be removed because it is not empty"))
      end
      return false
   else
      if not inv:is_empty("upgrade1") then
         minetest.item_drop(inv:get_stack("upgrade1", 1), "", pos)
   end
   return true
end
function technic.machine_after_dig_node(pos, oldnode, oldmetadata, player)
   if oldmetadata.inventory then
      if oldmetadata.inventory.upgrade1 and oldmetadata.inventory.upgrade1[1] then
         local stack = ItemStack(oldmetadata.inventory.upgrade1[1])
         if not stack:is_empty() then
            minetest.add_item(pos, stack)
         end
      end
      if not inv:is_empty("upgrade2") then
         minetest.item_drop(inv:get_stack("upgrade2", 1), "", pos)
      if oldmetadata.inventory.upgrade2 and oldmetadata.inventory.upgrade2[1] then
         local stack = ItemStack(oldmetadata.inventory.upgrade2[1])
         if not stack:is_empty() then
            minetest.add_item(pos, stack)
         end
      end
      return true
   end
   if minetest.registered_nodes[oldnode.name].tube then
      pipeworks.after_dig(pos, oldnode, oldmetadata, player)
   end
end