Advertisement
Scary_J

Untitled

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