Advertisement
klindley

Untitled

Jan 21st, 2017
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.73 KB | None | 0 0
  1. robot = require("component").robot
  2. sides = require("sides")
  3. ic = require("component").inventory_controller
  4. crafting = require("component").crafting
  5.  
  6. local selectedSlot = 13
  7. local usesRemaining = 72
  8.  
  9. local howMany = ...
  10. howMany = tonumber(howMany)
  11.  
  12. function turnAround()
  13. robot.turn(true)
  14. robot.turn(true)
  15. end
  16.  
  17. function craftItem()
  18. robot.select(1)
  19. ic.equip()
  20. crafting.craft(1)
  21. ic.equip()
  22. robot.select(selectedSlot)
  23. usesRemaining = 72
  24. end
  25.  
  26. function placeItem(dir)
  27. local success = true
  28. if robot.count(selectedSlot) == 0 then
  29. if (selectedSlot == 32) then
  30. return false, "Out of Items"
  31. end
  32. selectedSlot = selectedSlot + 1
  33. robot.select(selectedSlot)
  34. end
  35.  
  36. success = robot.place(dir)
  37.  
  38. robot.use(dir)
  39. usesRemaining = usesRemaining - 1
  40. craftItem()
  41. return success
  42. end
  43.  
  44. function placeBatbox()
  45. robot.select(29)
  46. robot.place(sides.up)
  47. robot.select(selectedSlot)
  48. end
  49.  
  50. function maint()
  51. local success = true;
  52. if (not placeItem(sides.down)) then
  53. return false
  54. end
  55. if (not robot.move(sides.back)) then return false, 1 end
  56. if (not placeItem(sides.forward)) then return false, 2 end
  57. if (not robot.move(sides.back)) then return false, 3 end
  58. if (not placeItem(sides.forward)) then return false, 4 end
  59. if (not robot.move(sides.back)) then return false, 5 end
  60. if (not placeItem(sides.forward)) then return false, 6 end
  61. robot.turn(true)
  62. if (not robot.move(sides.back)) then return false, 6 end
  63. if (not robot.move(sides.back)) then return false, 7 end
  64. if (not robot.move(sides.back)) then return false, 8 end
  65. if (not placeItem(sides.down)) then return false, 9 end
  66. turnAround()
  67. if (not robot.move(sides.back)) then return false, 10 end
  68. if (not placeItem(sides.forward)) then return false, 11 end
  69. if (not robot.move(sides.back)) then return false, 12 end
  70. if (not placeItem(sides.forward)) then return false, 13 end
  71. if (not robot.move(sides.back)) then return false, 14 end
  72. if (not placeItem(sides.forward)) then return false, 15 end
  73. if (not robot.move(sides.back)) then return false, 16 end
  74. if (not placeItem(sides.forward)) then return false, 17 end
  75. if (not robot.move(sides.back)) then return false, 18 end
  76. if (not placeItem(sides.forward)) then return false, 19 end
  77. if (not robot.move(sides.back)) then return false, 20 end
  78. if (not placeItem(sides.forward)) then return false, 21 end
  79. if (not placeItem(sides.down)) then return false, 22 end
  80.  
  81. if (not robot.move(sides.back)) then return false, 23 end
  82. if (not placeItem(sides.forward)) then return false, 24 end
  83. robot.turn(true)
  84. if (not robot.move(sides.back)) then return false, 25 end
  85. robot.turn(true)
  86. if (not robot.move(sides.back)) then return false, 26 end
  87. if (not robot.move(sides.back)) then return false, 27 end
  88. if (not robot.move(sides.back)) then return false, 28 end
  89. if (not robot.move(sides.back)) then return false, 29 end
  90. robot.turn(false)
  91. return true
  92. end
  93.  
  94. function connectt()
  95. if (not robot.move(sides.back)) then return false, 30 end
  96. if (not placeItem(sides.forward)) then return false, 31 end
  97. if (not robot.move(sides.back)) then return false, 32 end
  98. if (not placeItem(sides.forward)) then return false, 33 end
  99. placeBatbox()
  100. return true
  101. end
  102.  
  103. function reset()
  104. if (not robot.move(sides.back)) then return false, 34 end
  105. if (not robot.move(sides.back)) then return false, 35 end
  106. return true
  107. end
  108.  
  109. craftItem()
  110. robot.select(selectedSlot)
  111. local success = true
  112. local count = 1
  113. repeat
  114. if (not maint()) then break end
  115. if (not connectt()) then break end
  116. if (not maint()) then break end
  117. if (not reset()) then break end
  118. count = count + 1
  119. if count > howMany then success = false end
  120. until not success
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement