Advertisement
Guest User

chest

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