Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Digroom by itsmartin
- -- Prompts you for a room size, and then digs it out.
- -- Doesn't check for fuel level, ensure the turtle has enough fuel before you start.
- function dig3d(x, y, z)
- print("Digging a room " .. x .. " by " .. y .. " by " .. z .. ".")
- local layers = z
- local ascend = 0
- while layers >= 2 do
- dig2d(x, y, true)
- turtle.down()
- ascend = ascend + 1
- if layers >= 3 then
- turtle.digDown()
- turtle.down()
- ascend = ascend + 1
- end
- layers = layers - 2
- end
- if layers == 1 then
- dig2d(x, y, false)
- end
- for i = 1, ascend do
- turtle.up()
- end
- end
- function dig2d(x, y, digDown)
- local rows = x
- local farEnd = false
- while rows > 0 do
- dig1d(y, digDown)
- farEnd = not farEnd
- rows = rows - 1
- if rows > 0 then
- if farEnd then
- turtle.turnRight()
- digForward(digDown)
- turtle.turnRight()
- else
- turtle.turnLeft()
- digForward(digDown)
- turtle.turnLeft()
- end
- else
- -- Finished all rows, return back
- if digDown then
- turtle.digDown()
- end
- if farEnd then
- turtle.turnLeft()
- turtle.turnLeft()
- for i = 1, y-1 do
- turtle.forward()
- end
- end
- turtle.turnRight()
- for i = 1, x-1 do
- turtle.forward()
- end
- turtle.turnRight()
- end
- end
- end
- function dig1d(y, digDown)
- for i = 1, y-1 do
- digForward(digDown)
- end
- end
- function digForward(digDown)
- if digDown then
- turtle.digDown()
- end
- turtle.dig()
- local success = turtle.forward()
- while not success do
- turtle.dig()
- success = turtle.forward()
- end
- end
- print("How wide do you want the room? (Number of blocks to the right of the turtle to dig, including the turtle's current block)")
- local x = tonumber(read())
- print("How long do you want the room? (Number of blocks to the front of the turtle to dig, including the turtle's current block)")
- local y = tonumber(read())
- print("How deep do you want the room? (Number of blocks below the turtle to dig, including the turtle's current block)")
- local z = tonumber(read())
- dig3d(x,y,z)
Advertisement
Add Comment
Please, Sign In to add comment