Advertisement
Nicro

Quarry cover prototype

Dec 31st, 2014
599
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.76 KB | None | 0 0
  1. local fuelfail = 0
  2. local matfail = 0
  3. local movefail = 0
  4. local startfail = 1
  5. local matstart = 1
  6.  
  7. local function collision()
  8. print("I ran into something.")
  9. error()
  10. end
  11.  
  12. local function refuel()
  13. if turtle.getFuelLevel() < 10 then
  14. fuelfail = 0 else
  15. turtle.select(15)
  16. if not turtle.place() then
  17. collision()
  18. end
  19. turtle.suck(5)
  20. turtle.refuel()
  21. turtle.dig()
  22. turtle.select(1)
  23. fuelfail = fuelfail+1
  24. if fuelfail > 1 then
  25. print("I ran out of fuel.")
  26. error()
  27. else
  28. return refuel()
  29. end
  30. end
  31. end
  32.  
  33. local function material()
  34. turtle.select(1)
  35. if turtle.compareTo(14) then
  36. else
  37. turtle.drop()
  38. end
  39. while turtle.getItemCount() == 0 do
  40. turtle.select(16)
  41. if not turtle.place() then
  42. collision()
  43. end
  44. turtle.select(1)
  45. turtle.suck()
  46. turtle.select(16)
  47. turtle.dig()
  48. turtle.select(1)
  49. if not turtle.compareTo(14) and matstart == 1 then
  50. print("The material enderchest is not")
  51. print("providing the right thing,")
  52. print("please check it's position in the inventory.")
  53. error()
  54. else
  55. matstart = 0
  56. end
  57. matfail = matfail+1
  58. if matfail > 1 then
  59. print("I ran out of material.")
  60. error()
  61. else
  62. end
  63. end
  64. matfail = 0
  65. end
  66.  
  67. local function advDig()
  68. while turtle.detect() do
  69. turtle.dig()
  70. if turtle.detect() then
  71. os.sleep(0.8)
  72. end
  73. end
  74. end
  75. while true do
  76. advDig()
  77. refuel()
  78. material()
  79. turtle.select(1)
  80. if not turtle.forward() then
  81. collision()
  82. end
  83. if turtle.detectDown() and startfail == 1 then
  84. print("I think I started in the wrong spot, ")
  85. print("please place me in a")
  86. print("valid starting position.")
  87. error()
  88. end
  89. if startfail == 1 then
  90. startfail = 0
  91. end
  92. if turtle.detectDown() then
  93. movefail = movefail+1
  94. if movefail > 1 then
  95. print("I think I am done.")
  96. error()
  97. else turtle.back()
  98. turtle.turnRight()
  99. end
  100. else
  101. movefail = 0
  102. turtle.placeDown()
  103. end
  104. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement