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

Problems with yet another tree farming bot.

Started by Xenogami, 10 February 2013 - 01:58 PM
Xenogami #1
Posted 10 February 2013 - 02:58 PM
Hi there,

Im fairly new to this and I have been banging my head against this program for a few days now. The code is at http://pastebin.com/dS3vaDe3

Saplings go in slot 1, fuel goes in slot 2. I want it to harvest/plant 7 rows and 7 columns then return back to the start and wait 2 min while the trees regrow then start over.

It starts off fine, but every now and then it will just stop in the middle of a tree, some times going up the tree some times going down. It also won't change columns. There are probably several other bugs with it, but thats as far as I'v got in my testing.

Thanks in advance for any advice you can give

Xeno
Lyqyd #2
Posted 11 February 2013 - 12:58 AM
Split into new topic.
Doyle3694 #3
Posted 11 February 2013 - 01:51 AM
first of :

while turtle.detectDown() == false do
Is a bad way of checking booleans for true or false, you are basically saying "If false is false return true", however, you can simply invert all booleans with "not", so that code would become

while not turtle.detectDown() do
That is about effiency and making your code easier to read, doesn't change much.

For the program, I cannnot spot a problem just looking at it. Your explanation is very weak, try to explain it further and maybe even add a screenshot or two? :)/> Also, 6 space indentions are really hard to read, atleast imo :)/>

EDIT: reading through your code some more, I found that you should remove the turtle.forward() in the end of your nextColumn() function. It will make him go 1 more step forward than I think you want him too.
Xenogami #4
Posted 11 February 2013 - 05:35 AM
Thanks for the advice with the booleans, I made that change in the code.

When i sad it just stops in the middle of a tree what it is doing is getting stuck in the chopTime() function right at


if turtle.detect() then
   turtle.dig()
   turtle.forward()
   while turtle.detectUp() do
	  turtle.digUp()
	  turtle.up()
   end
   while not turtle.detectDown() do
	  turtle.down()
   end
   turtle.back()
end

It does not error out and tell me what line, it just stops with the program still running i have to use ctrl+t to stop it.
Xenogami #5
Posted 11 February 2013 - 11:53 AM
Im playing on a friends server using the FTB mod pack. Here is a screen shot of the turtle frozen after it finished cutting down a tree and on the way back down. Again it didn't give an error it just stoped moving with the program sill running.

Doyle3694 #6
Posted 11 February 2013 - 12:08 PM
derpy question, but did he run out of fuel?
Xenogami #7
Posted 12 February 2013 - 03:01 AM
I have a function to keep him fueled up, but I did go ahead and check after the 2nd time he froze up and he had around 214 fuel. Even if it was out of fuel, the turtle.turnLeft() and turtle.turnRight() would make him move.
Doyle3694 #8
Posted 12 February 2013 - 03:28 AM
Try troubleshooting with a print after each line in the function and run it, to narrow down the problem to 1 line
Xenogami #9
Posted 13 February 2013 - 08:09 AM
Good idea, I'm going to be busy with school for a few days, but I will give that a shot this weekend. Thanks for the help Doyle3694.