Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Conor's excavating program!!")
- write("Please enter the length: ")
- local length = tonumber(read())
- write("Please enter the width: ")
- local width = tonumber(read())
- write("Please enter the depth: ")
- local depth = tonumber(read())
- local function checkFuel()
- if turtle.getFuelLevel() < 200 then
- for i = 1, 16 do
- turtle.select(i)
- if turtle.refuel(0) then
- turtle.refuel(1)
- end
- end
- end
- end
- local function left(currentDepth, depth)
- turtle.turnLeft()
- turtle.dig()
- if currentDepth + 1 < depth then
- turtle.digDown()
- end
- turtle.forward()
- turtle.turnLeft()
- end
- local function right(currentDepth, depth)
- turtle.turnRight()
- turtle.dig()
- if currentDepth + 1 < depth then
- turtle.digDown()
- end
- turtle.forward()
- turtle.turnRight()
- end
- local function excavate(length, width, depth)
- if depth > 1 then
- turtle.digDown()
- end
- local i = 0
- local z = 1
- --for i = 1, depth do
- while i < depth do
- for j = 1, width do
- checkFuel()
- for k = 1, length - 1 do
- if i + 1 < depth then
- turtle.digDown()
- end
- turtle.dig()
- turtle.forward()
- end
- if j < width then
- -- if even width
- if width % 2 == 0 then
- -- if even depth
- if z % 2 == 0 then
- if j % 2 == 0 then
- right(i, depth)
- else
- left(i, depth)
- end
- -- if odd depth
- else
- if j % 2 == 0 then
- left(i, depth)
- else
- right(i, depth)
- end
- end
- -- if odd width
- else
- if j % 2 == 0 then
- left(i, depth)
- else
- right(i, depth)
- end
- end
- end
- end
- -- position turtle if more than 0 depth to go
- if i + 1 < depth then
- turtle.turnRight()
- turtle.turnRight()
- turtle.digDown()
- turtle.down()
- if i + 2 < depth then
- turtle.digDown()
- turtle.down()
- end
- end
- if i + 1 < depth then
- i = i + 2
- elseif i < depth then
- i = i + 1
- end
- z = z + 1
- end
- end
- excavate(length, width, depth)
Add Comment
Please, Sign In to add comment