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

[Lua][Error][Turtle] bios:338: error

Started by Cranken, 30 December 2012 - 01:57 AM
Cranken #1
Posted 30 December 2012 - 02:57 AM
Hey
I wanted to make a programm to fell my trees(4 big) like this:
function tree()

	if
	turtle.attack()
	then
	turtle.forward()

	else
	turtle.digup()
	turtle.up()
	turtle.turnLeft()

end
(I know there are missing some parts but i just wanted to know how to fix the error)

But i get this error:

bios:338: [string "tree"]:14: ´end´expected (to close ´function´at line 1)

What did i do wrong?
FalloutBe #2
Posted 30 December 2012 - 03:17 AM
You forgot the 'end' for your if-else structure:

function tree()
 if turtle.attack() then
  turtle.forward()
 else
  turtle.digup()
  turtle.up()
  turtle.turnLeft()
 end --!!!
end