Advertisement
ScoutMaester

Untitled

Sep 6th, 2023 (edited)
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1. length = 1
  2. currentLength = 0
  3. width = 1
  4. currentWidth = 0
  5. height = 1
  6. currentHeight = 0
  7. onOddRow= true
  8. confirmed = "y"
  9. skipAirSpaces = false
  10.  
  11. -- Asking user for input
  12. print "How far am I going?"
  13. length = tonumber(read())
  14. print "How wide is the tunnel?"
  15. width = tonumber(read())
  16. print "How high am I going?"
  17. height = tonumber(read())
  18. print "Skip empty spaces above? (y/n)"
  19. _ = read()
  20. if (_ == "y") then
  21. skipAirSpaces = true
  22. end
  23.  
  24. function GetFuelLevel()
  25. local coal = 0
  26. local details = turtle.getItemDetail()
  27. while coal == 0 do
  28. print ("I have " ..turtle.getFuelLevel().. " fuel")
  29. print ("Would you like to add more fuel? y/n")
  30. input = read()
  31. if input("y") then
  32. print "Confirmed"
  33. else
  34. print "Please add coal to slot 1"
  35. turtle.select(1)
  36. print "Please confirm when done <Enter>"
  37. input = read()
  38. if details.name ~= "minecraft.coal" then
  39. print "I do not see coal in slot 1"
  40. else
  41. print "Refueling"
  42. turtle.refuel()
  43. coal = 1
  44. end
  45. end
  46. end
  47. end
  48.  
  49. function Poke()
  50. if (onOddRow) then
  51. if (currentLength < length - 1) then
  52. turtle.dig()
  53. end
  54. else
  55. if (currentLength > 1) then
  56. turtle.dig()
  57. end
  58. end
  59. end
  60.  
  61. function Advance()
  62. Poke()
  63. turtle.forward()
  64. if onOddRow then
  65. currentLength = currentLength + 1
  66. else
  67. currentLength = currentLength - 1
  68. end
  69. end
  70. function AdvanceUpward ()
  71. turtle.digUp()
  72. turtle.up()
  73. currentHeight = currentHeight + 1
  74. end
  75. function AdvanceDownward ()
  76. turtle.digDown()
  77. turtle.down()
  78. currentHeight = currentHeight - 1
  79. end
  80.  
  81. function DigUpToTop(poke)
  82. if height < 2 then return end
  83.  
  84. while currentHeight < height do
  85. if (skipAirSpaces and turtle.detectUp() == false) then
  86. break
  87. end
  88. Poke()
  89. AdvanceUpward()
  90. end
  91. end
  92.  
  93. function DigDownToZero (poke)
  94. while currentHeight > 0 do
  95. Poke()
  96. AdvanceDownward()
  97. end
  98. end
  99.  
  100. function Turn ()
  101. if onOddRow then
  102. turtle.turnRight()
  103. else
  104. turtle.turnLeft()
  105. end
  106. end
  107.  
  108. function UTurn ()
  109. Turn()
  110. Advance()
  111. DigUpToTop()
  112. DigDownToZero()
  113. Turn()
  114. end
  115.  
  116. while (currentWidth < width) do
  117. currentWidth = currentWidth + 1
  118.  
  119. atDestination = false
  120. while not atDestination do
  121. if (onOddRow) then
  122. currentLength = currentLength + 1
  123. atDestination = (currentLength >= length)
  124. else
  125. currentLength = currentLength - 1
  126. atDestination = (currentLength <= 0)
  127. end
  128. Advance()
  129. DigUpToTop()
  130. Advance()
  131. DigDownToZero()
  132. end
  133.  
  134. UTurn()
  135. onOddRow = not onOddRow
  136.  
  137. end
  138.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement