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

Something's wrong with my door lock?

Started by Lewis.holcombe, 26 February 2013 - 11:17 AM
Lewis.holcombe #1
Posted 26 February 2013 - 12:17 PM
Hey guys I'm going to put a pastebin file below and when I start this program it gives me an error. The program is called password but it will be renamed to startup.
Password:6: attempt to index? (A nil value)
Http://pastebin.com/V43rSgSW
Kingdaro #2
Posted 26 February 2013 - 12:21 PM
"textutils" is misspelled on line 6.
SuicidalSTDz #3
Posted 26 February 2013 - 12:37 PM
term.clear()
term.setCursorPos(1,1)
password = "zxcvbnm"
print"Holcombeshost OS 0.01"
textutils.slowPrint("Booting into secure password lock system 0.01")
textutiles.slowPrint("[************************************************]")
print"Booted into Holcombeshost secure password lock"
sleep(3)
input = read("*")
write"Password: "
if input == password then
  textutils.slowPrint("Verifying password...")
  textutils.slowPrint("Password was correct")
  print"You now have access thru the door for 3 secconds"
  rs.setOutput("bottom",true)
  sleep(3)
  rs.setOutput("bottom",false)
  os.shutdown()
else
  textutils.slowPrint("Veriying password...")
  textutils.slowPrint("Password was incorrect")
  print"System will now log time, date and user"
  textutils.slowPrint("[*************************************************]")
  print"Logged"
  print"System will now shutdown"
  sleep(3)
  os.shutdown()
end

This all looks good but it is a good habit to enclose lines with parenthesis when needed. It won't error but it looks cleaner.

For example:

print"Hello"
print("Hello")

It doesn't matter which way, but it is cleaner the second way.
Kingdaro #4
Posted 26 February 2013 - 12:39 PM
@SuicidalSTDz, I disagree. The only problem I have with that is that there's no space between print and "Hello". Other than that, I would say that it looks way cleaner without parentheses than with, and it's less typing in the longrun.
SuicidalSTDz #5
Posted 26 February 2013 - 12:43 PM
@SuicidalSTDz, I disagree. The only problem I have with that is that there's no space between print and "Hello". Other than that, I would say that it looks way cleaner without parentheses than with, and it's less typing in the longrun.
Meh, I think it looks cleaner. Also, I was born to type ;)/> Doesn't bother me at all. But that's just my opinion. Feel free to use either method you want, your code, your rules (Well sort of).

EDIT: Just easier for me since most things in any language must be enclosed with parenthesis to indicate a call


I would define a variable like this to avoid typing if that's the case:

sp = textutils.slowPrint
Lewis.holcombe #6
Posted 26 February 2013 - 12:55 PM
Thanks for the help guys. I'm going to delete this thread now! + first time I used pastebin and its genuinely amazing!
SuicidalSTDz #7
Posted 26 February 2013 - 12:59 PM
Thanks for the help guys. I'm going to delete this thread now! + first time I used pastebin and its genuinely amazing!
I think I can safely say, Kingdaro and I both are happy to help :)/>
Skullblade #8
Posted 26 February 2013 - 01:22 PM
U can't delete threads…
SuicidalSTDz #9
Posted 26 February 2013 - 02:26 PM
U can't delete threads…
Sure you can… (In our dreams :D/>)