Advertisement
Scary_J

Untitled

May 23rd, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 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 vor()
  57. if (turtle.getFuel() > (betrag_x()+betrag_y()+4)) then
  58. turtle.forward()
  59. if (dir == 0) then
  60. x = x + 1
  61. elseif (dir == 1) then
  62. y = y + 1
  63. elseif (dir == 2) then
  64. x = x - 1
  65. elseif (dir == 3) then
  66. y = y - 1
  67. end
  68. end
  69. end
  70.  
  71. local function dig()
  72. if (turtle.getFuel() > (betrag(x) + betrag(y) + 4)) and notfull() then
  73. turtle.dig()
  74. vor()
  75. turtle.digUp()
  76. end
  77. end
  78.  
  79. local function left()
  80. turtle.turnLeft()
  81. if dir > 0 then
  82. dir = dir - 1
  83. else
  84. dir = 3
  85. end
  86. end
  87.  
  88. local function right()
  89. turtle.turnRight()
  90. if dir < 3 then
  91. dir = dir + 1
  92. else
  93. dir = 0
  94. end
  95. end
  96.  
  97. local function home()
  98. term.clear()
  99. term.setCursorPos(1,1)
  100. print("HOME")
  101. end
  102.  
  103. local function stripdig()
  104. left()
  105. while (y > (-1)*strip) do
  106. dig()
  107. end
  108. left()
  109. left()
  110. while (y ~= 0) do
  111. vor()
  112. end
  113. while (y < strip) do
  114. dig()
  115. end
  116. left()
  117. left()
  118. while (y ~= 0) do
  119. vor()
  120. end
  121. right()
  122. end
  123.  
  124.  
  125.  
  126.  
  127.  
  128. -- (x < tunnel) and (turtle.getFuel() > (betrag_x()+betrag_y()+4)) and (notfull())
  129.  
  130.  
  131.  
  132. eingabe()
  133.  
  134. term.clear()
  135. term.setCursorPos(1,1)
  136. print("Progress...")
  137.  
  138. while true do
  139. if (x%3) == 2 then
  140. stripdig()
  141. end
  142.  
  143. dig()
  144.  
  145. end
  146.  
  147. home()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement