This program is for ComputerCraft 1.41. It will not work in 1.3, and is unknown to work in 1.42, though it probably does. It will clear an area with military precision, in a user-specified area. It may leave the ceiling of houses though, which is due to its movements, conserving time and fuel.
It will place a torch, destroy it, and move on. If it cannot place said torch, it places cobble or dirt in the perceived hole. This means it destroys all transparent blocks beneath it. It will then check above it, and if there is something above it, it destroys it.
This program is potent, it will level a mountain if you set it upon it. Once you get used to its movements, it is quite predictable. I hope you enjoy. As ever, if you have any feedback, or have encountered any bugs, please tell me!
1.41
Spoiler
function refuel()
if turtle.getFuelLevel() < 10 then
turtle.select(16)
turtle.refuel(1)
end
end
function moveForward()
repeat
turtle.dig()
until turtle.forward()
end
function clear()
local z = 0
if turtle.detectUp() then
while turtle.detectUp() do
repeat
turtle.digUp()
until turtle.up()
z = z+1
end
repeat
turtle.down()
z = z-1
if z < 0 then
repeat
turtle.up()
z = z+1
until z == 0
end
until z == 0
end
end
function test()
turtle.select(15)
if turtle.detectDown() then
turtle.digDown()
end
if not turtle.placeDown() then
turtle.digDown()
turtle.down()
turtle.digDown()
turtle.select(14)
turtle.placeDown()
turtle.up()
end
turtle.digDown()
end
print "How wide is this foundation?"
x = tonumber(read())
print "How long?"
y = tonumber(read())
print "Please place fuel in slot 16, two torches in slot 15, and dirt/stone in 14. Press any key to start."
os.pullEvent("key")
x = x-1
y = y/2
refuel()
turtle.turnLeft()
turtle.digUp()
turtle.up()
for i = 1,x/2 do
test()
clear()
moveForward()
refuel()
end
turtle.turnLeft()
turtle.turnLeft()
for i = 1,x do
test()
clear()
moveForward()
refuel()
end
for i = 1,y+0.5 do
turtle.turnLeft()
test()
clear()
moveForward()
refuel()
turtle.turnLeft()
for i = 1,x do
test()
clear()
moveForward()
refuel()
end
turtle.turnRight()
test()
clear()
moveForward()
refuel()
turtle.turnRight()
for i = 1,x do
test()
clear()
moveForward()
refuel()
end
end
test()
clear()
–Lettuce