Advertisement
Scary_J

Untitled

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