Advertisement
Guest User

chest

a guest
Jan 31st, 2015
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.03 KB | None | 0 0
  1. comp = require("component")
  2. sides = require("sides")
  3. robot = require("robot")
  4. count = 0
  5.  
  6. function clear()
  7.   robot.use()
  8.   require("os").sleep(2)
  9.   robot.use()
  10. end
  11.  
  12. function scanChest()
  13.     local inv = comp.inventory_controller.getStackInSlot(sides.front, 1)
  14.     if(inv == nil) then    
  15.          return true
  16.     else
  17.         return false
  18.     end
  19. end
  20.    
  21. function fill()
  22.     robot.turnAround()
  23.     comp.inventory_controller.suckFromSlot(sides.front, 1, 1)
  24.     robot.turnAround()
  25.     comp.inventory_controller.dropIntoSlot(sides.front, 1, 1)
  26. end
  27.  
  28. function scanFill()  
  29.   if scanChest() then
  30.     fill()
  31.   end
  32. end
  33.  
  34. function colFill()
  35.   for i=1, 3 do
  36.     scanFill()
  37.     robot.up()
  38.   end
  39. end
  40.  
  41. function nextCol()
  42.   robot.down()
  43.   robot.down()
  44.   robot.down()
  45.   robot.turnLeft()
  46.   robot.forward()
  47.   robot.turnRight()
  48. end
  49.  
  50. function reset(count)
  51.   robot.turnRight()
  52.   for i=1, count do
  53.     robot.forward()
  54.   end
  55. end
  56.  
  57. function main()
  58.   clear()
  59.   robot.turnLeft()
  60.   for i=1, 5 do
  61.     colFill()
  62.     nextCol()
  63.     count = count + 1
  64.   end
  65.   reset(count)
  66. end
  67.  
  68. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement