This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Lettuce's profile picture

[CC 1.41] Lettuce's Improved Land-Clearing Program

Started by Lettuce, 13 August 2012 - 10:32 PM
Lettuce #1
Posted 14 August 2012 - 12:32 AM
Hello World! With some help and a lot of debugging by luanub, we have updated my land-clearing program! It cuts grass now! For those of you who aren't familiar with it, here's a rundown:

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
Sammich Lord #2
Posted 14 August 2012 - 12:53 AM
Awesome code!
I would suggest uploading to pastebin and putting the code in spoiler tags.
skraginator #3
Posted 14 August 2012 - 06:10 AM
What is the getFuellevel for? I was getting an error about a nil value, I was thinking it was the turtle.select(16) since turtles dont have 16 slots.. I'll put all the code back in a try again, the server I'm on doesn't have support for loading pastebin files.

ok put the code back in as you pasted it. when i try to run it asks width and length then after i input it gives me 'flatten:51: attempt to call nil
Lettuce #4
Posted 14 August 2012 - 06:51 AM
Human 0303, glad ya like it! First program upload. I've never used pastebin, and I don't know how to use spoiler tags. If you tell me how, I will.

skraginator, updated my post, I forgot to mention it's for 1.4. Just backup your custom programs and update CC to 1.4, which works for minecraft 1.2.5, or delete all things related to fuel. Then this should work fine.
skraginator #5
Posted 14 August 2012 - 10:50 AM
Blargh! server isnt updated to support 1.4 :P/>/>
mtemple12 #6
Posted 18 August 2012 - 08:40 PM
Just edit out the getFuelLevel calls. Should work just fine :(/>/>
flashy99 #7
Posted 28 September 2012 - 03:21 PM
When I run this, it works for a little while but always stops long before it's finished. There's still plenty of fuel in it, and inventory slots are available. It's not because the chunk is unloading, because I've stood next to the turtle the entire time and watched it work until at some point it just freezes and sits there in mid-air.
Lettuce #8
Posted 02 October 2012 - 01:15 AM
As this has been updated to version 2.0, I am bumping it. I didn't want to open a new thread for an update.
doctorwhofan92 #9
Posted 30 April 2019 - 09:53 PM
Is there any chance this will be updated to work with the current(1.12.2) version of computercraft?
KingofGamesYami #10
Posted 01 May 2019 - 12:04 AM
Is there any chance this will be updated to work with the current(1.12.2) version of computercraft?

OP hasn't logged in since 2015 so I rather doubt they will respond.
LDDestroier #11
Posted 01 May 2019 - 05:50 AM
I don't know what you mean. This program seems to work just fine in 1.12.2. Just tested in the SwitchCraft technic pack.