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

"eof" expected error

Started by deadcrypt, 20 November 2015 - 01:28 PM
deadcrypt #1
Posted 20 November 2015 - 02:28 PM
heres the code please escuse my bad indenting


while true do
  term.clear()
  term.setCursorPos(1, 1)
  print("please enter your login information")
  sleep(1)
  print(" ")
  print("Username:")
  local yourinput = read()
  if input == "Test" then end
  print("Password:")
  sleep(0)
  input = read("*")
  if input == "Test" then end
  redstone.setOutput("back", true)
  print("Information correct")
  sleep(2)
  os.reboot()
end
else
print("Intruder detected sounding alarms")
sleep(1)
redstone.setOutput("right", true)
sleep(10)
redstone.setOutput("right", false)
sleep(1)
os.reboot()
end
end
Lupus590 #2
Posted 20 November 2015 - 04:32 PM
eof means end of file

as an error, it means that you have too many ends.

Indenting your code properly helps a lot, I also commented your ends, so that you can see which one ends what. additionally I moved some of your ends onto a separate line


while true do
  term.clear()
  term.setCursorPos(1, 1)
  print("please enter your login information")
  sleep(1)
  print(" ")
  print("Username:")
  local yourinput = read()
  if input == "Test" then
    --#stuff to do in if goes here
  end --#if
  print("Password:")
  sleep(0)
  input = read("*")
  if input == "Test" then
    --#stuff to do in if goes here
  end--#if
  redstone.setOutput("back", true)
  print("Information correct")
  sleep(2)
  os.reboot()
end --#while
else --#this should cause a problem, as you have ended your if statements already
print("Intruder detected sounding alarms")
sleep(1)
redstone.setOutput("right", true)
sleep(10)
redstone.setOutput("right", false)
sleep(1)
os.reboot()
end --#nothing to end
end --#nothing to end
Edited on 20 November 2015 - 03:33 PM