auouymous
2021-02-06 0f7810e53895f5742ab577559584539e6533a0dc
technic/machines/register/common.lua
@@ -65,16 +65,16 @@
   if output_name == nil then
      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
            item0["count"] = "1"
         if item0 then
            item0["count"] = 1
            technic.tube_inject_item(pos, pos, vector.new(x_velocity, 0, z_velocity), item0)
            stack:take_item(1)
            inv:set_stack(output_name, i, stack)
@@ -83,7 +83,6 @@
      end
   end
end
function technic.smelt_item(meta, result, speed)
   local inv = meta:get_inventory()
@@ -109,10 +108,9 @@
   if send_function == nil then
      send_function = technic.send_items
   end
   local node = minetest.get_node(pos)
   local meta = minetest.get_meta(pos)
   local inv = meta:get_inventory()
   local pos1 = vector.new(pos)
   local x_velocity = 0
   local z_velocity = 0
@@ -124,7 +122,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
@@ -138,19 +136,38 @@
   meta:set_int("tube_time", tube_time)
end
function technic.machine_can_dig(pos, player)
   local meta = minetest.get_meta(pos)
   local inv = meta:get_inventory()
   if not inv:is_empty("src") or not inv:is_empty("dst") or
      not inv:is_empty("upgrade1") or not inv:is_empty("upgrade2") then
   if not inv:is_empty("src") or not inv:is_empty("dst") then
      if player then
         minetest.chat_send_player(player:get_player_name(),
            S("Machine cannot be removed because it is not empty"))
      end
      return false
   else
      return true
   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 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
   end
   if minetest.registered_nodes[oldnode.name].tube then
      pipeworks.after_dig(pos, oldnode, oldmetadata, player)
   end
end