Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- length = 1
- currentLength = 0
- width = 1
- currentWidth = 0
- height = 1
- currentHeight = 0
- onOddRow= true
- confirmed = "y"
- skipAirSpaces = false
- -- Asking user for input
- print "How far am I going?"
- length = tonumber(read())
- print "How wide is the tunnel?"
- width = tonumber(read())
- print "How high am I going?"
- height = tonumber(read())
- print "Skip empty spaces above? (y/n)"
- _ = read()
- if (_ == "y") then
- skipAirSpaces = true
- end
- function GetFuelLevel()
- local coal = 0
- local details = turtle.getItemDetail()
- while coal == 0 do
- print ("I have " ..turtle.getFuelLevel().. " fuel")
- print ("Would you like to add more fuel? y/n")
- input = read()
- if input("y") then
- print "Confirmed"
- else
- print "Please add coal to slot 1"
- turtle.select(1)
- print "Please confirm when done <Enter>"
- input = read()
- if details.name ~= "minecraft.coal" then
- print "I do not see coal in slot 1"
- else
- print "Refueling"
- turtle.refuel()
- coal = 1
- end
- end
- end
- end
- function Poke()
- if (onOddRow) then
- if (currentLength < length - 1) then
- turtle.dig()
- end
- else
- if (currentLength > 1) then
- turtle.dig()
- end
- end
- end
- function Advance()
- Poke()
- turtle.forward()
- if onOddRow then
- currentLength = currentLength + 1
- else
- currentLength = currentLength - 1
- end
- end
- function AdvanceUpward ()
- turtle.digUp()
- turtle.up()
- currentHeight = currentHeight + 1
- end
- function AdvanceDownward ()
- turtle.digDown()
- turtle.down()
- currentHeight = currentHeight - 1
- end
- function DigUpToTop(poke)
- if height < 2 then return end
- while currentHeight < height do
- if (skipAirSpaces and turtle.detectUp() == false) then
- break
- end
- Poke()
- AdvanceUpward()
- end
- end
- function DigDownToZero (poke)
- while currentHeight > 0 do
- Poke()
- AdvanceDownward()
- end
- end
- function Turn ()
- if onOddRow then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- end
- function UTurn ()
- Turn()
- Advance()
- DigUpToTop()
- DigDownToZero()
- Turn()
- end
- while (currentWidth < width) do
- currentWidth = currentWidth + 1
- atDestination = false
- while not atDestination do
- if (onOddRow) then
- currentLength = currentLength + 1
- atDestination = (currentLength >= length)
- else
- currentLength = currentLength - 1
- atDestination = (currentLength <= 0)
- end
- Advance()
- DigUpToTop()
- Advance()
- DigDownToZero()
- end
- UTurn()
- onOddRow = not onOddRow
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement