Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- config
- local width = 0
- local length = 0
- local linecount = 0
- local dblocks = 0 -- blocks dug so far minus air
- local tblocks = 0 -- total blocks in area
- local mblocks = 0 -- current line progress
- local goneleft = false -- has turtle gone left yet
- --functions start
- --clear
- function clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- --dig line
- local function line()
- mblocks = 0
- while mblocks < length do
- if turtle.dig() == true then
- dblocks = dblocks+1
- end
- while turtle.forward() ~= true do
- os.sleep(0.5)
- end
- mblocks = mblocks+1
- end
- print("dug " .. dblocks .. "/" .. tblocks .. " blocks.")
- linecount = linecount+1
- end
- -- turn left and dig a line
- local function lineleft()
- turtle.turnLeft()
- if turtle.dig() == true then
- dblocks = dblocks+1
- end
- while turtle.forward() ~= true do
- os.sleep(0.5)
- end
- turtle.turnLeft()
- line()
- end
- -- turn right and dig a line
- local function lineright()
- turtle.turnRight()
- if turtle.dig() == true then
- dblocks = dblocks+1
- end
- while turtle.forward() ~= true do
- os.sleep(0.5)
- end
- turtle.turnRight()
- line()
- end
- --begin code
- clear()
- print("Place turtle above block at bottom right of area.")
- write("Enter Width: ")
- width = tonumber(read())
- write("Enter Length: ")
- length = tonumber(read()-1)
- tblocks = ((length+1)*(width))
- if turtle.digDown() == true then
- dblocks = dblocks+1
- end
- turtle.down()
- line()
- while linecount < width do
- if goneleft == true then
- lineright()
- goneleft = false
- else
- lineleft()
- goneleft = true
- end
- end
- print("Done. Mined " .. dblocks .. " out of " .. tblocks .. " blocks total.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement