Advertisement
DiamondQ2

ProcessSift

Oct 19th, 2014
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.51 KB | None | 0 0
  1. robot = require("robot")
  2. component = require("component")
  3. sides = require("sides")
  4. inv = component.inventory_controller
  5. craft = component.crafting
  6. items = { "19021:0", "19025:0", "19028:0", "19031:0", "19035:0", "19039:0", "19042:0", "19046:0", "19050:0", "19054:0",
  7.     "19108:2", "19110:2", "19112:2",  "19114:2", "19117:2", "19120:2", "19123:2", "19124:2", "19125:2", "19126:2",
  8.     "19127:2", "19132:2"}
  9.  
  10. function checkForPul()
  11.     local size = inv.getInventorySize(sides.front)
  12.     for x=1,size do
  13.         local info = inv.getStackInSlot(sides.front, x)
  14.         if (type(info) ~= "nil") then
  15.             for _,c in ipairs(items) do
  16.                 if (c == tostring(info.id) .. ":" .. tostring(info.damage)) then
  17.                     if (info.size > 4) then
  18.                         robot.select(1)
  19.                         local count = math.floor((info.size - 1) / 4) * 4
  20.                         if (inv.suckFromSlot(sides.front, x, count) == false) then
  21.                             return -2
  22.                         end
  23.                         if (robot.transferTo(2, count / 4) == false) then
  24.                             return -2
  25.                         end
  26.                         if (robot.transferTo(5, count / 4) == false) then
  27.                             return -2
  28.                         end
  29.                         if (robot.transferTo(6, count / 4) == false) then
  30.                             return -2
  31.                         end
  32.                         if (craft.craft() == false) then
  33.                             return -2
  34.                         end
  35.                         robot.select(1)
  36.                         if (robot.dropDown() == false) then
  37.                             return -2
  38.                         end
  39.                         return x
  40.                     end
  41.                 end
  42.             end
  43.         end
  44.     end
  45.     return -1
  46. end
  47.  
  48. while (1 == 1) do
  49.     local ans = checkForPul()
  50.     if (ans == -1) then
  51.         os.sleep(5)
  52.     elseif (ans == -2) then
  53.         print("Failed")
  54.         os.exit()
  55.     end
  56. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement