Evan Phelps
Evan Phelps

Reputation: 19

New to Lua, confused by error <eof>

I recently started taking an interest in Lua programming with a Minecraft addon called Computercraft, which involves console-based GUIs to control computers and other things with Lua. However, I seem to be randomly getting an error where the code requires something called an "eof". I have searched multiple manuals and how-tos, and none mention this particular error. In fact, I am having trouble finding anything with an error list. I am fairly new to programming, but have had basic Python experience. Could anyone explain what "eof" is?

Upvotes: 1

Views: 20460

Answers (3)

David Robson
David Robson

Reputation: 312

Using ESPlorer there is a difference between "uploading" a script and "sending" a script. Use "Upload".

This is not the same issue as the one reported, but as searching landed me here...

Upvotes: 0

Keaton mcguirk
Keaton mcguirk

Reputation: 21

An eof is do or then.

Usually eof means you have too many (or not enough) end statements. Paste code maybe?

Upvotes: 2

rakslice
rakslice

Reputation: 8975

Suppose I create a file with one too many end statements:

> edit test.lua

for i = 1, 10 do
  print(i)
end
end

When I run it, and lua encounters that extra end statement on the last line where there is no code block still open, you'll get an error like:

> test.lua

bios: 337: [string "test.lua"]: 4: '<eof>' expected

(from a quick test in CCDesk pr7.1.1)

Problems with the basic structure of the blocks of lua code show up with bios on the left rather than your file name; the part of bios that loads lua files will usually tell you where it was at in the file when couldn't make sense of the code anymore (like line 4: here). Sometimes it might be a bit of a puzzle to work your way from the scene of the accident back to where things got off track. =)

Upvotes: 0

Related Questions