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

Help fast!

Started by NeptunasLT, 12 March 2013 - 11:04 PM
NeptunasLT #1
Posted 13 March 2013 - 12:04 AM
My code:
write("Password: ")
if input == start then
print("Booting System")
remiX #2
Posted 13 March 2013 - 12:30 AM
input = read()
if input == "start" then
Shuudoushi #3
Posted 13 March 2013 - 12:44 AM
um…
Use this as a base….

http://pastebin.com/2w0JZ9QJ
or
http://pastebin.com/W9yH2c10

If you use the "debug" code as the main input then it will work fine for your needs.
theoriginalbit #4
Posted 13 March 2013 - 02:25 AM

write("Password: ")
local input = read()
if input:lower() == 'start' then
  print("Booting System")
else
  print("Goodbye")
  os.shutdown()
end
Simon #5
Posted 14 March 2013 - 06:02 AM

write("Password: ")
local input = read()
if input:lower() == 'start' then
  print("Booting System")
else
  print("Goodbye")
  os.shutdown()
end
What does the :lower() do?
Lyqyd #6
Posted 14 March 2013 - 06:05 AM
Since input is a string, it's syntactically equivalent to `string.lower(input)`, which converts all upper-case letters to lower-case letters. You can guess what string.upper does.
theoriginalbit #7
Posted 14 March 2013 - 06:46 PM
To expand on what Lyqyd said, its so that even if they enter it like StARt it will still work because it is converted to lower case before checking what they typed.