Guest User

newer bad code

a guest
Feb 27th, 2014
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. local col = 1
  2. local loc = 1
  3.  
  4. function fuel()
  5. while true do
  6. if turtle.getFuelLevel() < 50 then
  7. print("current fuel is " ..turtle.getFuelLevel().. " need 50+")
  8. print("Please insert fuel source in slot 1")
  9. for i=1, 16 do
  10. turtle.select(i)
  11. turtle.refuel()
  12. end
  13. break
  14. else
  15. break
  16. end
  17. end
  18. end
  19.  
  20. function go()
  21. while not turtle.forward() do
  22. fuel()
  23. turtle.dig()
  24. turtle.attack()
  25. sleep(.5)
  26. end
  27. vDig()
  28. end
  29.  
  30. function clear()
  31. term.clear()
  32. term.setCursorPos(1,1)
  33. end
  34.  
  35. function up()
  36. loc = loc + 1
  37. turtle.up()
  38. end
  39.  
  40. function yCount()
  41. turtle.digUp()
  42. up()
  43. end
  44.  
  45. function vDig()
  46.  
  47. repeat yCount()
  48. until turtle.detectUp() == false
  49. if turtle.detectUp() == false then
  50. for i=1, 4 do
  51. yCount()
  52. end
  53. end
  54.  
  55.  
  56. for u=1, loc do
  57. turtle.down()
  58. end
  59. loc = 1
  60. end
  61.  
  62.  
  63. function forward()
  64. for i=1, x do
  65. if turtle.detectDown() == false then
  66. turtle.select(2)
  67. turtle.placeDown()
  68. else
  69. go()
  70. end
  71. end
  72. end
  73.  
  74.  
  75.  
  76.  
  77. term.write("How many blocks forward? ")
  78. x = tonumber(io.read())
  79. clear()
  80.  
  81. while true do
  82. print("Do you want the turtle to turn")
  83. print("Right or Left? R/L ")
  84. local event, param1 = os.pullEvent ("char")
  85. if param1 == "l" then
  86. print(" You chose Left! ")
  87. direction = "Left"
  88.  
  89. sleep(2)
  90. break
  91.  
  92. elseif param1 == "r" then
  93. print("You chose Right! ")
  94. direction = "Right"
  95. sleep(2)
  96. break
  97. else
  98. print ("Not valid!")
  99. sleep(1.5)
  100. clear()
  101. end
  102. end
  103.  
  104. clear()
  105.  
  106. print("How many blocks to the " ..direction)
  107. print("do you want to go? ")
  108. y = tonumber(io.read())
  109.  
  110.  
  111.  
  112. clear()
  113. print("Checking fuel...")
  114. sleep(2)
  115. fuel()
  116. sleep(2)
  117.  
  118.  
  119. if direction == "Left" then
  120. print("Starting! Left! ")
  121. else
  122. print("Starting! Right!")
  123. end
  124. for i=1,y do
  125. forward()
  126.  
  127. if i < y then
  128. if direction == "Left" then
  129. turtle.turnLeft()
  130. go()
  131. turtle.turnLeft()
  132. direction = "Right"
  133. else
  134. turtle.turnRight()
  135. go()
  136. turtle.turnRight()
  137. direction = "Left"
  138. end
  139. end
  140. end
  141.  
  142. clear()
Advertisement
Add Comment
Please, Sign In to add comment