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

Login system help

Started by sleawnis, 25 November 2012 - 04:38 AM
sleawnis #1
Posted 25 November 2012 - 05:38 AM
I've made a password protection for my computer, but I need a username/ password. I was thinking like first it starts on username, on input it adds 1 to x, when x is 2 it changes cursor to password then sum how checks? Could sum1 whip up me a code? ;p thanks
remiX #2
Posted 25 November 2012 - 05:54 AM

term.setCursorPos(1,3)
print("Username: ")
print("Password: ")
term.setCursorPos(11, 3)
userName = read()
term.setCursorPos(11, 4)
passWord = read()
billysback #3
Posted 25 November 2012 - 05:57 AM
Well remix has given you the code already but for future referance, please don't just as for code, at lease make some attempt at creating it, or do some research.

Not having a go, just mentioning it :D/>/>
sleawnis #4
Posted 25 November 2012 - 06:14 AM
Ok thankyou but how would I like make it say recognised or whatever after user? Sorry I'm iPod so quite hard to type :D/>/>
Zudo #5
Posted 25 November 2012 - 06:21 AM
Just use userName and passWord variables
user = "CHEESE"
pass = "CAKE"
term.setCursorPos(1,3)
print("Username: ")
print("Password: ")
term.setCursorPos(11, 3)
userName = read()
term.setCursorPos(11, 4)
passWord = read()
if userName = user and passWord = pass then
print("Logged in")
else
print("Error")
end
sleawnis #6
Posted 25 November 2012 - 07:43 AM
thankyou :D/>/>
Laserman34170 #7
Posted 25 November 2012 - 12:32 PM
Just use userName and passWord variables
user = "CHEESE"
 pass = "CAKE" 
term.setCursorPos(1,3)
 print("Username: ")
 print("Password: ")
 term.setCursorPos(11, 3)
 userName = read()
 term.setCursorPos(11, 4)
 passWord = read()
 if userName = user and passWord = pass then 
print("Logged in")
else
 print("Error") 
end
There's an error here. On the if statements there should be 2 equal signs. Below is what it should be.

if userName == user and passWord == pass then