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

Automatic Treefarm - Turtle won't do anything neither throw an error

Started by UselessCookie, 13 September 2014 - 09:59 AM
UselessCookie #1
Posted 13 September 2014 - 11:59 AM
Hey guys,

I've been recently working on a automatic Treefarm on my FTB Unleashed server.
Since me and some other friends need more wood, I started programming this.

For some reason, when I start the Program, the turtle doesn't move, also it doesn't give me an error message.

Heres The Code

while true do

function Check()
  turtle.select(2)
	if compare() == true then
	  Abbau()
	 else
	end
  
function Abbau()
  turtle.turnRight()
  turtle.turnLeft()
end
  
function Place(int)
  turtle.place()
  sleep(int)
end
function Initialisierung()
  turtle.select(1)
  turtle.turnRight()
  turtle.suck()
  turtle.select(2)
  turtle.suck()
  turtle.turnLeft()
  turtle.select(1)
end

  Initialisierung()
  Place(30)
  Check()
  Abbau()
end
end

Sorry if it's mixed with German, but here I explain the functions:
Initialisierung() == Gets stuff out of the chest which is at the right of the turtle
Place(30) == selects saplings in slot 1 and places one, then sleeps 30 seconds
Check() == Selects wood in slot 2 and checks, if there is wood in front of the turtle. If yes, it starts the function Abbau()
Abbau() == Right now it just should make the turtle turn left and right again, so I can see if it has made it to the Abbau() function.

When I start the program though, the turtle doesn't move in the beginning, doesn't get stuff out of the chest, doesn't even throw an error.
What is going on?

Btw I'm a ComputerCraft beginner :P/>

Also a stupid question, how do I make spoilers?

Hope you guys can help me.
Lyqyd #2
Posted 13 September 2014 - 03:17 PM
You've got your ends in the wrong places, so everything is inside the Check function, which you never call (since the only call to it is inside the function itself).
Bomb Bloke #3
Posted 13 September 2014 - 03:20 PM
Sorting out the indentation makes Lyqyd's point easier to see:

Spoiler
while true do
	function Check()
		turtle.select(2)
		if compare() == true then
			Abbau()
		else
		end

		function Abbau()
			turtle.turnRight()
			turtle.turnLeft()
		end

		function Place(int)
			turtle.place()
			sleep(int)
		end
		function Initialisierung()
			turtle.select(1)
			turtle.turnRight()
			turtle.suck()
			turtle.select(2)
			turtle.suck()
			turtle.turnLeft()
			turtle.select(1)
		end

		Initialisierung()
		Place(30)
		Check()
		Abbau()
	end
end

See the problem?

Spoiler tags are written thusly: [spoiler][/spoiler]
Dragon53535 #4
Posted 13 September 2014 - 03:58 PM
After doing that you WILL get an error as compare() should be turtle.compare() at line 4