Guest User

Error

a guest
Feb 28th, 2013
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. local location = ""
  2.  
  3. function teleport()
  4. tp = peripheral.wrap("bottom")
  5. tp.teleport()
  6. end
  7.  
  8. function checkFull()
  9. greader = peripheral.wrap("right")
  10. data = greader.get()
  11. while not data["Full Energy"] do
  12. sleep(2)
  13. data=greader.get()
  14. end
  15. turtle.dig()
  16. end
  17.  
  18. function checkEmpty()
  19. greader=peripheral.wrap("right")
  20. data = greader.get()
  21. while not data["No Energy"] do
  22. sleep(2)
  23. data = greader.get()
  24. end
  25. turtle.dig()
  26. end
  27.  
  28. function checkLoc()
  29. loc = turtle.detectUp()
  30. if loc == true then
  31. print("I am at the quarry")
  32. location = "Quarry"
  33. if turtle.getItemCount(1) > 0 then turtle.turnRight() end
  34. else
  35. print("I am at the charge station")
  36. location = "Charging"
  37. if turtle.getItemCount(1) > 0 then
  38. turtle.turnRight()
  39. turtle.forward()
  40. turtle.forward()
  41. end
  42. end
  43. end
  44.  
  45. function getFuel()
  46. turtle.turnRight()
  47. for i = 1, 9 do turtle.forward() end
  48. turtle.turnLeft()
  49. for i = 1, 6 do turtle.forward() end
  50. turtle.suck()
  51. turtle.refuel()
  52. turtle.turnLeft()
  53. turtle.turnLeft()
  54. for i = 1, 6 do turtle.forward() end
  55. turtle.turnRight()
  56. for i = 1, 9 do turtle.forward() end
  57. turtle.turnRight()
  58. end
  59.  
  60.  
  61. function checkFuel()
  62. fuel = turtle.getFuelLevel()
  63. print("My fuel level:"..tostring(fuel))
  64. if fuel < 1000 then
  65. print("I need fuel")
  66. getFuel()
  67. print("My fuel level:"..tostring(turtle.getFuelLevel()))
  68. end
  69. end
  70.  
  71.  
  72. checkLoc()
  73. if location == "Quarry" then
  74. turtle.place()
  75. checkEmpty()
  76. teleport()
  77. else
  78. turtle.place()
  79. checkFuel()
  80. checkFull()
  81. turtle.turnLeft()
  82. turtle.turnLeft()
  83. turtle.forward()
  84. turtle.forward()
  85. teleport()
  86. end
Advertisement
Add Comment
Please, Sign In to add comment