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

'end' expected

Started by Ratzmutz, 06 April 2014 - 11:09 AM
Ratzmutz #1
Posted 06 April 2014 - 01:09 PM
Hello!
I wrote a program and everytime I start it I get the error "bios:339: [string "pathfinding"]:9: 'end' expected (to close 'function' at line 1)"

Can anyone help me?
function anfang()
--Forwaerts/forward
turtle.forward()
if turtle.compareDown() == true then
  anfang()
end
else then
  turtle.back()
end
--Rechts/right
turtle.turnRight()
turtle.forward()
if turtle.compareDown() == true then
  anfang()
end
else then
  turtle.back()
  turtle.turnLeft()
end
--Links/left
turtle.turnLeft()
turtle.forward()
if turtle.compareDown() == true then
  anfang()
end
else then
  turtle.back()
  turtle.turnRight()
end
end
  
while true do
anfang()
end


sorry for my bad english :-)
CometWolf #2
Posted 06 April 2014 - 09:03 PM
You're using the end statements incorrectly.

function functionName()
  --function here
end
if variable then
  --stuff
else
  --otherstuff
end
Edited on 06 April 2014 - 07:03 PM
RoD #3
Posted 06 April 2014 - 09:46 PM
This post is everywhere in the forums… And theres a lot of solutions in the forum and other websites. You need to search more before asking general questions. But you are new and i understand it. Good luck with the code and wellcome to the CC Forums. :)/>