DeMmAge

KeyTest

Aug 24th, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. local robot = require("robot")
  2. local comp = require("computer")
  3.  
  4. function jack()
  5. while robot.detect() do
  6. if not robot.up() then
  7. robot.swingUp()
  8. robot.up()
  9. end
  10. end
  11. while not robot.detectDown() do
  12. robot.down()
  13. robot.swing()
  14. end
  15. robot.place()
  16. robot.up()
  17. end
  18. function unload()
  19. robot.turnAround()
  20. robot.down()
  21. for c = 2, 16 do
  22. robot.select(c)
  23. if robot.count() > 0 then
  24. robot.drop()
  25. end
  26. end
  27. robot.select(1)
  28. robot.up()
  29. robot.turnAround()
  30. end
  31.  
  32. while true do
  33. robot.up()
  34. if robot.detect() then
  35. jack()
  36. if robot.count(2) == 64 then
  37. unload()
  38. end
  39. end
  40. robot.down()
  41.  
  42. if comp.energy() < 10 then
  43. print("Error! Low energy level.")
  44. break
  45. end
  46.  
  47. os.sleep(15)
  48. end
Add Comment
Please, Sign In to add comment