Advertisement
Scary_J

Untitled

May 23rd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. local strip = 0
  2. local tunnel = 0
  3. local userinput = ""
  4. local dir = 0
  5. local x = 0
  6. local y = 0
  7.  
  8. local a = 0
  9. local b = 0
  10. local c = false
  11. local d = 0
  12.  
  13. local function eingabe()
  14. local bool = true
  15.  
  16.  
  17.  
  18. while bool do
  19. term.setCursorPos(1,1)
  20. term.clear()
  21. print("Wie Lang soll der Tunnel sein?")
  22. print(" >> ")
  23. tunnel = tonumber(read())
  24.  
  25. if tunnel > 9 then
  26. print("Wie Lang sollen die Seitengaenge sein?")
  27. print(" >> ")
  28. strip = tonumber(read())
  29.  
  30. if strip > 2 then
  31. bool = false
  32. else
  33. term.setCursorPos(1,1)
  34. term.clear()
  35. end
  36.  
  37. else
  38. term.setCursorPos(1,1)
  39. term.clear()
  40. end
  41. end
  42. end
  43.  
  44.  
  45.  
  46. local function notfull()
  47. for i = 1, 16 do
  48. if turtle.getItemCount(i) == 0 then
  49. return true
  50. end
  51. end
  52. return false
  53. end
  54.  
  55. local function betrag(x)
  56. if (x < 0) then
  57. return ((-1)*x)
  58. else
  59. return x
  60. end
  61. end
  62.  
  63. local function vor()
  64. a = betrag(x)
  65. b = betrag(y)
  66. c = notfull()
  67. d = turtle.getFuel()
  68. if (d) > (a + b + 4)) and c then
  69. turtle.forward()
  70. if (dir == 0) then
  71. x = x + 1
  72. elseif (dir == 1) then
  73. y = y + 1
  74. elseif (dir == 2) then
  75. x = x - 1
  76. elseif (dir == 3) then
  77. y = y - 1
  78. end
  79. end
  80. end
  81.  
  82. local function dig()
  83. a = betrag(x)
  84. b = betrag(y)
  85. c = notfull()
  86. d = turtle.getFuel()
  87. if (d) > (a + b + 4) and c then
  88. turtle.dig()
  89. vor()
  90. turtle.digUp()
  91. end
  92. end
  93.  
  94. local function left()
  95. turtle.turnLeft()
  96. if dir > 0 then
  97. dir = dir - 1
  98. else
  99. dir = 3
  100. end
  101. end
  102.  
  103. local function right()
  104. turtle.turnRight()
  105. if dir < 3 then
  106. dir = dir + 1
  107. else
  108. dir = 0
  109. end
  110. end
  111.  
  112. local function home()
  113. term.clear()
  114. term.setCursorPos(1,1)
  115. print("HOME")
  116. end
  117.  
  118. local function stripdig()
  119. left()
  120. while (y > (-1)*strip) do
  121. dig()
  122. end
  123. left()
  124. left()
  125. while (y ~= 0) do
  126. vor()
  127. end
  128. while (y < strip) do
  129. dig()
  130. end
  131. left()
  132. left()
  133. while (y ~= 0) do
  134. vor()
  135. end
  136. right()
  137. end
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146. eingabe()
  147.  
  148. term.clear()
  149. term.setCursorPos(1,1)
  150. print("Progress...")
  151.  
  152. a = betrag(x)
  153. b = betrag(y)
  154. c = notfull()
  155. d = turtle.getFuel()
  156.  
  157. while (d) > (a + b + 4)) and c do
  158. if (x%3) == 2 then
  159. stripdig()
  160. end
  161.  
  162. dig()
  163. a = betrag(x)
  164. b = betrag(y)
  165. c = notfull()
  166. d = turtle.getFuel()
  167. end
  168.  
  169. home()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement