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

Why is this error popping up?

Started by MoRBiiD Legacy, 09 April 2015 - 07:56 PM
MoRBiiD Legacy #1
Posted 09 April 2015 - 09:56 PM
I am trying to make a startup code for a multi function defence system, which i have not finished, but every time i try to launch it on my advanced terminal, i get <eof> error on line 46… why?

shell.run("clear")
print("Welcome to MoRBiiD's cannon control terminal!")
sleep(5)
print("What is your command?")
print("arm, deactivate") – No deactivation yet…
local input = read()
if (input) == ("arm") then
shell.run("clear")
print("Loading…")
sleep(2)
shell.run("clear")
print("Fire, arrow or tnt?") – No TNT yet…
local input = read()
if (input) == ("fire") then
shell.run("clear")
print(".")
sleep(1)
shell.run("clear")
print("..")
sleep(1)
shell.run("clear")
print("…")
sleep(1)
shell.run("clear")
redstone.setBundledOutput("back", colors.red)
sleep(1)
redstone.setBundledOutput("back", 0)
print("Done.")
end
elseif (input) == ("arrow") then
shell.run("clear")
print(".")
sleep(1)
shell.run("clear")
print("..")
sleep(1)
shell.run("clear")
print("…")
sleep(1)
shell.run("clear")
redstone.setBundledOutput("back", colors.white)
sleep(1)
redstone.setBundledOutput("back", 0)
print("Done.")
end
end – <eof> expected?
sleep(2)
shell.run("startup")
KingofGamesYami #2
Posted 09 April 2015 - 10:00 PM
<eof> expected means you have too many ends somewhere in your code. Proper indentation can reveal this:


shell.run("clear")
print("Welcome to MoRBiiD's cannon control terminal!")
sleep(5)
print("What is your command?")
print("arm, deactivate") -- No deactivation yet...
local input = read()
if (input) == ("arm") then 
  shell.run("clear") 
  print("Loading...") 
  sleep(2) 
  shell.run("clear") 
  print("Fire, arrow or tnt?") -- No TNT yet...
  local input = read()
  if (input) == ("fire") then
    shell.run("clear")
    print(".")
    sleep(1)
    shell.run("clear")
    print("..")
    sleep(1)
    shell.run("clear")
    print("...")
    sleep(1)
    shell.run("clear")
    redstone.setBundledOutput("back", colors.red)
    sleep(1)
    redstone.setBundledOutput("back", 0)
    print("Done.")
  end --#here
  elseif (input) == ("arrow") then
    shell.run("clear")
    print(".")
    sleep(1)
    shell.run("clear")
    print("..")
    sleep(1)
    shell.run("clear")
    print("...")
    sleep(1)
    shell.run("clear")
    redstone.setBundledOutput("back", colors.white)
    sleep(1)
    redstone.setBundledOutput("back", 0)
    print("Done.")
  end
end -- <eof> expected?
sleep(2)
shell.run("startup") 

Also, I'd take a look at textutils.slowPrint ;)/>
MoRBiiD Legacy #3
Posted 09 April 2015 - 10:07 PM
<eof> expected means you have too many ends somewhere in your code. Proper indentation can reveal this:


shell.run("clear")
print("Welcome to MoRBiiD's cannon control terminal!")
sleep(5)
print("What is your command?")
print("arm, deactivate") -- No deactivation yet...
local input = read()
if (input) == ("arm") then
  shell.run("clear")
  print("Loading...")
  sleep(2)
  shell.run("clear")
  print("Fire, arrow or tnt?") -- No TNT yet...
  local input = read()
  if (input) == ("fire") then
	shell.run("clear")
	print(".")
	sleep(1)
	shell.run("clear")
	print("..")
	sleep(1)
	shell.run("clear")
	print("...")
	sleep(1)
	shell.run("clear")
	redstone.setBundledOutput("back", colors.red)
	sleep(1)
	redstone.setBundledOutput("back", 0)
	print("Done.")
  end --#here
  elseif (input) == ("arrow") then
	shell.run("clear")
	print(".")
	sleep(1)
	shell.run("clear")
	print("..")
	sleep(1)
	shell.run("clear")
	print("...")
	sleep(1)
	shell.run("clear")
	redstone.setBundledOutput("back", colors.white)
	sleep(1)
	redstone.setBundledOutput("back", 0)
	print("Done.")
  end
end -- <eof> expected?
sleep(2)
shell.run("startup")

Also, I'd take a look at textutils.slowPrint ;)/>

thx it worked! i didnt think the problem was that i had too many "end"s but that i needed another (end of function EXPECTED) Now to blow up my friend's house > :D/> and btw i never thought that any slow print was possible, so thats why there are so many print>sleep>clear mini functions, thx for the advice!
Edited on 09 April 2015 - 08:12 PM
KingofGamesYami #4
Posted 09 April 2015 - 11:27 PM
eof stands for end of file (if there are too many ends, it'll do something like '<eof> expected').
Edited on 09 April 2015 - 09:28 PM