Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Input
- print("This program will remove all blocks in an area defined by the following parameters.")
- print("")
- print("------------------------------------------------------------------------------")
- print("")
- print("Enter area length.")
- local length = tonumber(io.read())
- length = length or 5
- print("Area length set to: " .. length .. " blocks.")
- print("")
- print("Enter area width.")
- local width = tonumber(io.read())
- width = width or length
- print("Area width set to: " .. width .. " blocks.")
- print("")
- print("Should the turtle move left or right?")
- print("Type 0 or leave blank for Right.")
- print("Type 1 for Left.")
- local hdir = tonumber(io.read())
- hdir = hdir or 0
- if (hdir ~= 1) then
- hdir = 0
- hdirst = "Right"
- else
- hdir = 1
- hdirst = "Left"
- end
- hhdir = hdir
- print("Turtle will move " .. hdirst)
- print("")
- print("Should the turtle move up or down?")
- print("Type 0 or leave blank for down.")
- print("Type 1 for up.")
- local vdir = tonumber(io.read())
- vdir = vdir or 0
- if (vdir ~= 1) then
- vdir = 0
- vdirst = "Down"
- else
- vdir = 1
- vdirst = "Up"
- end
- print("Turtle will move " .. vdirst)
- print("")
- print("How far vertically should the turtle travel?")
- print("Leave blank for 1")
- local height = tonumber(io.read())
- height = height or 1
- if (height < 2) then
- height = 1
- end
- print("Area height set to: " .. height .. " blocks.")
- print("")
- print("---------------------------------------")
- print("")
- print("Removing a " .. length .. "x" .. width .. "x" .. height .. " area to the " .. hdirst .. " of the turtle, digging " .. vdirst .. ".")
- --Functions
- function checkfuel()
- if turtle.getFuelLevel() < 10 then
- for i = 1, 16 do
- turtle.select(i)
- turtle.refuel(1)
- end
- turtle.select(1)
- end
- end
- function turnaround()
- turtle.turnRight()
- sleep(0.1)
- turtle.turnRight()
- sleep(0.1)
- end
- function dig()
- while turtle.detect() do
- turtle.dig()
- sleep(0.5)
- end
- end
- function digUp()
- while turtle.detectUp() do
- turtle.digUp()
- sleep(0.5)
- end
- end
- function digDown()
- while turtle.detectDown() do
- turtle.digDown()
- sleep(0.5)
- end
- end
- function nextcolumn()
- for i = (vdir + 1), height do
- checkfuel()
- if vdir == 1 then
- turtle.down()
- else
- turtle.up()
- end
- end
- end
- function backlength()
- turnaround()
- for i = 1, length do
- dig()
- checkfuel()
- turtle.forward()
- end
- turnaround()
- end
- function dircheck()
- if hdir == 0 then
- turtle.turnRight()
- dig()
- checkfuel()
- turtle.forward()
- turtle.turnLeft()
- else
- turtle.turnLeft()
- dig()
- checkfuel()
- turtle.forward()
- turtle.turnRight()
- end
- end
- --Main
- for w = 1, width do
- dig()
- checkfuel()
- turtle.forward()
- for l = 1, length do
- for h = (vdir + 1), height do
- if vdir == 1 then
- digUp()
- checkfuel()
- turtle.up()
- else
- digDown()
- checkfuel()
- turtle.down()
- end
- end
- nextcolumn()
- if l < length then
- dig()
- checkfuel()
- turtle.forward()
- end
- end
- backlength()
- if w < width then
- dircheck()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement