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

[lua] [error] <eof> Expected

Started by RoflDisney, 16 November 2013 - 11:52 AM
RoflDisney #1
Posted 16 November 2013 - 12:52 PM
I don't know what this means, I get this error:

bios:338: [string "Slots"]:177: '<eof>' expected

heres my code: http://pastebin.com/Kxutf445


Please help!
Bomb Bloke #2
Posted 16 November 2013 - 05:48 PM
It would normally mean you've put in an "end" statement that's trying to close a code block that isn't there. For eg:

local function myExample()
  -- Some code goes here
end
end -- This shouldn't be here; since it is, Lua takes it to mean the whole program should be ended...

print("Hello!") -- ... but since there's more code underneath it, it throws your error ("I thought I'd reached End Of File!")

Catch is, the code in your paste doesn't have this problem. I'm guessing that isn't actually what's saved on your CC computer's drive - on the off chance that it is, then I'd recommend rebooting that computer.

By the way:

Don't try to subtract ".0" from your variables, this does literally nothing. If you have a variable that prints with a ".0" on the end, print it as eg "tostring(result1)" - this'll chop the end bit off.

At the bottom, you have:

    if redstone.getInput("back") then
      if redstone.getInput("back") == true then

These effectively check for the same thing: The first line checks to see if the condition "redstone.getInput("back")" is true. The second line checks to see if the condition "redstone.getInput("back")" is true, is true. There's never any point in actually typing out "== true".

If you wanted to see if "redstone.getInput("back")" was false, you'd use "if not redstone.getInput("back") then".

You could cut down the length of your code a lot if you implemented your own "print" function for use with your monitor (to implement line breaks automatically). A primitive version would go along the lines of:

local function monitorPrint(text)
  mon.write(text)
  local monx,mony = mon.getCursorPos()
  mon.setCursorPos(1,mony+1)
end

"os.pullEvent("redstone")" automatically blocks until it specifically finds a redstone event.