Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Length: ")
- local length = io.read()
- print("Width: ")
- local width = io.read()
- print("Height: ")
- local height = io.read()
- function turn(diretion, steps)
- if not direction then
- direction = "right"
- end
- if not steps then
- steps = 1
- end
- if direction == "left" then
- for i=1,steps do
- turtle.turnLeft()
- end
- elseif direction == "right" then
- for i=1,steps do
- turtle.turnRight()
- end
- else return false end
- return true
- end
- function move()
- if turtle.detect() then
- turtle.dig()
- return turtle.forward()
- else
- return turtle.forward()
- end
- end
- function newRow(rowCount, direction)
- if not (direction == "left" or direction == "right") then
- return false
- end
- local secondDir = function()
- if direction == "left" then
- return "right"
- end
- return "left"
- end
- if rowCount%2 ~= 0 then
- turn(direction)
- if not move() then return false end
- turn(direction)
- else
- turn(secondDir)
- if not move() then return false end
- turn(secondDir)
- end
- return true
- end
- function newCol()
- turtle.digDown()
- turtle.down()
- turn("right",2)
- end
- function mineAll(l,w,h)
- function leftOrRight(rowCount)
- if rowCount%2 == 0 then return "left" end
- return "right"
- end
- for hi = 1,h do
- print("Mining layer: ", hi, "/", h)
- for wi=1,w do
- print("Mining row: ", wi, "/", w)
- for li=1,l do
- if not move() then
- return false
- end
- end
- if not wi >= w then newRow(wi, leftOrRight(wi)) end
- end
- if not hi >= h then newCol() end
- end
- return true
- end
- function main()
- print("Total blocks to mine: ", length*width*height)
- mineAll(length, width, height)
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement