3 posts
Location
The Nether around 24000, 62, 1296
Posted 29 June 2013 - 01:19 AM
Title - (Noob-CC-Coder) 'End' expected (to close ' function')
ok i am a noob at computercraft its the only thing in FTB that i couldn't use at all (excluding mining turtle excavate, and tunnel)
so i decided to learn. I have watched a bit of direwolf20 (2-3 seasons) and started using the wiki. But enough non-sense.
I tried to make myself a auto harvest/replant program that does not use bonemeal (all the ones i found do) and i got this error
Bios : 337 : [string "FarmBot"] :107 : 'end' expected (to close 'function' at line 5)
can some1 tell me how to fix or help me finish my code?
pastebin code here "vb4rkuQD"
P.S. How do you use spoilers?
8543 posts
Posted 29 June 2013 - 02:26 PM
Split into new topic.
1522 posts
Location
The Netherlands
Posted 29 June 2013 - 03:30 PM
Spoiler
function Seed()
turtle.select(1)
end
function EmptyInv()
turtle.turnRight()
turtle.turnRight()
for i = 3, 16 do
turtle.select(i)
turtle.drop()
turtle.turnRight()
turtle.turnRight()
end
function Harvest()
turtle.forward()
turtle.digDown()
Seed()
turtle.placeDown()
end
function rowA()
Harvest()
Harvest()
Harvest()
Harvest()
Harvest()
Harvest()
Harvest()
Harvest()
Harvest()
turtle.forward()
turtle.turnRight()
turtle.forward()
turtle.turnRight()
end
function rowB()
Harvest()
Harvest()
Harvest()
Harvest()
Harvest()
Harvest()
Harvest()
Harvest()
Harvest()
turtle.forward()
turtle.turnLeft()
turtle.forward()
turtle.turnLeft()
end
function rowC()
Harvest()
Harvest()
Harvest()
Harvest()
turtle.forward()
Harvest()
Harvest()
Harvest()
Harvest()
turtle.forward()
turtle.turnRight()
turtle.forward()
turtle.turnRight()
end
function Home()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.turnRight()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.turnRight()
end
while true do
rowA()
rowB()
rowA()
rowB()
rowC()
rowB()
rowA()
rowB()
rowA()
Home()
EmptyInv()
sleep(3600)
end
Spoiler made with Spoiler
tags! :)/>/>I compressed the code with for-loops and correct indentation:
Spoiler
function Seed()
turtle.select(1)
end
function EmptyInv()
turtle.turnRight()
turtle.turnRight()
for i = 3, 16 do
turtle.select(i)
turtle.drop()
turtle.turnRight()
turtle.turnRight()
end -- # You missed an end right here
end
function Harvest()
turtle.forward()
turtle.digDown()
Seed()
turtle.placeDown()
end
function rowA()
for i = 1, 8 do
Harvest()
end
turtle.forward()
turtle.turnRight()
turtle.forward()
turtle.turnRight()
end
function rowB()
for i = 1, 9 do
Harvest()
end
turtle.forward()
turtle.turnLeft()
turtle.forward()
turtle.turnLeft()
end
function rowC()
for i = 1, 4 do
Harvest()
end
turtle.forward()
for i = 1, 4 do
Harvest()
end
turtle.forward()
turtle.turnRight()
turtle.forward()
turtle.turnRight()
end
function Home()
for i = 1, 10 do
turtle.forward()
end
turtle.turnRight()
for i = 1, 9 do
turtle.forward()
end
turtle.turnRight()
end
while true do
rowA()
rowB()
rowA()
rowB()
rowC()
rowB()
rowA()
rowB()
rowA()
Home()
EmptyInv()
sleep(3600)
end
So, you have to close a for-loop to with end. Otherwise Lua doesnt know what commands it should execute in the for-loop.
3 posts
Location
The Nether around 24000, 62, 1296
Posted 30 June 2013 - 03:05 AM
Thanx Engineer Close Topic Please!!!!
159 posts
Location
A Chair
Posted 01 July 2013 - 04:38 AM
:)/> it sometimes needs an extra set of eyes. Like Engineer I also spotted the missing end statement after a few seconds…
Lua is pretty good at showing you where to look for an error.
Bios : 337 : [string "FarmBot"] :107 : 'end' expected (to close 'function' at line 5)
This tells us that at line 107 the end statement is trying to close the function at line 5. This means there is a missing end statement somewhere between line 107 and 5.
so if you scan your code from line 5 downwards, noting each opening statement and checking for the close of that statement… you will find the error by process of elimination. (indentation helps with this kind of error finding - start a statement on the same indentation as you finish it on)