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

io:10: unsupported format

Started by mistertimn, 28 May 2014 - 03:50 AM
mistertimn #1
Posted 28 May 2014 - 05:50 AM
I'm writing a password program to unlock a computer, and I am modelling it after the RobCo Termlink from Fallout. I want the user to be able to enter the password after a '>' purely for aesthetics. The program will run right until I hit enter to submit the password, after which i get the error 'io:10: unsupported format.' The only thing of line 10 is a function to centre text that I found on the forum. Is putting the '>' before the password entry screwing the program up?

Code:
Spoiler

password = "yourpasshere"
ovr = "vaulttecovr"
hack = "set terminal/inquire"
function header()
print("WELCOME TO ROBCO INDUSTRIES (TM) TERMLINK")
print(" ")
end
function centerText(text)
x,y = term.getSize()
x2,y2 = term.getCursorPos()
term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
write(text)
end
function command()
io.write("> ")
cmd = io.read()
if cmd == "logon admin" then
  print(" ")
  print("ENTER PASSWORD NOW")
  print(" ")
  write("> ")
  pass = io.read("*")
  if pass == password then
   term.clear()
   term.setCursorPos(1,1)
   -- shell.run("TERMPROGRAMHERE")
   centerText("ROBCO INDUSTRIES UNIFIED OPERATING SYSTEM")
   centerText("COPYRIGHT 2075-2077 ROBCO INDUSTRIES")
   centerText("-Server 1-")
   print(" ")
   sleep(1)
  else
   print(" ")
   print("INVALID PASSWORD")
   sleep(2)
   os.shutdown()
  end
elseif cmd == ovr then
  -- end program
elseif cmd == hack then
  -- shell.run("hack")
else
  print(" ")
  print("INVALID COMMAND")
  sleep(2)
  command()
end
end
-- main code
header()
command()
Lyqyd #2
Posted 28 May 2014 - 06:16 AM
If you want to use a masking character, use read, not io.read.