Advertisement
Scary_J

Untitled

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