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

[LUA][ERROR]<eof> expected

Started by StoneJustStone, 15 November 2012 - 08:30 AM
StoneJustStone #1
Posted 15 November 2012 - 09:30 AM
This is the function I try to call when I get the Error.

Pastebin

I call it with:

return docking()

or just

docking()

None of them work. I am not so fimiliar with LUA but have been programming java for quite some time; I feel kind of embarrassed. :P/>/>

Please help me with this. Thanks in advance!

EDIT:

Well, it's probably the way I call the function.

When I use "return docking()" it says bios:338: [String "<program name>"]:3: '<eof>' expected. (code)

When I just use "docking()" I get <program name>:2: attempt to call nil
Orwell #2
Posted 15 November 2012 - 09:37 AM
I heavily doubt that this is all of your code, because I can't see anything wrong with it. The error you get is typically produced when you have an end too few or too many. (It means 'end of file' and actually means that lua found code to parse when it didn't expect any anymore).
Fiery Arcanine #3
Posted 15 November 2012 - 09:42 AM
Make pairs with statement openings (if etc.) and end
you have (like orwell said) too many end statements
Cranium #4
Posted 15 November 2012 - 09:52 AM
This function does work. This can't be all of your code. What line error are you getting, and what is the rest of your code?
Luanub #5
Posted 15 November 2012 - 10:10 AM
If this is all of you code the only problems I see are you don't need to put the return in front of the function call, and the call needs to be after the function is declared. Lua works top down, if it hasn't read it yet it doesn't exist.

Should look like:


function docking()

		turtle.select(1)
		turtle.dropUp()
		turtle.suckUp()

		for i = 2, 16 do
				turtle.select(i)
				turtle.drop()
		end

		turtle.turnRight()
		turtle.turnRight()
end

docking()

EDIT: The ends and everything are correct, this is one of the cases where you get an EOF without having issues with ends.
StoneJustStone #6
Posted 15 November 2012 - 10:17 AM
If this is all of you code the only problems I see are you don't need to put the return in front of the function call, and the call needs to be after the function is declared. Lua works top down, if it hasn't read it yet it doesn't exist.

Should look like:


function docking()

		turtle.select(1)
		turtle.dropUp()
		turtle.suckUp()

		for i = 2, 16 do
				turtle.select(i)
				turtle.drop()
		end

		turtle.turnRight()
		turtle.turnRight()
end

docking()

EDIT: The ends and everything are correct, this is one of the cases where you get an EOF without having issues with ends.

Oh, thanks, I thought It would just execute the code since it's the first function in the code!