klindley

Wiring2

Jan 31st, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 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. craftItem()
  45. robot.select(selectedSlot)
  46. local success = true
  47. local count = 1
  48. repeat
  49. placeItem(sides.forward)
  50. robot.move(sides.back)
  51. count = count + 1
  52. if count > howMany then success = false end
  53. until not success
Add Comment
Please, Sign In to add comment