Posted 17 June 2014 - 04:05 PM
Ok, so, I made a little program where users can get a hotel room. (Well, just by telling the user what room number they are in.) And I was doing all that when I spotted a problem.
THE CODE:
Thank you for reading this thread, and if you do actually take time looking at it and helping this program, that would mean a lot. If you can't understand what the problem is, I'm very sorry. I'm at a young age.
THE CODE:
password = math.random(1000,9999)
function register()
term.clear()
term.setCursorPos(5,10)
write"Password: "
passwordA = read()
if passwordA == password then -------THIS IS THE PROBLEM. On this if else statement, it always goes to the "else" instead of the "if" part. I did type in the correct number password, but it doesn't
room = math.random(1,5) work
term.clear()
term.setCursorPos(5,10)
print("Your Room Number Is "..room..".")
term.setCursorPos(5,11)
print("Have a nice day!")
sleep(5)
os.reboot()
else
term.clear()
term.setCursorPos(5,10)
print("That Password is invalid. Please notify")
term.setCursorPos(5,11)
print("a staff member.")
sleep(5)
os.reboot()
end
end
term.clear() -------- PROGRAM STARTS HERE
term.setCursorPos(5,10)
write"Password for Password: "
passwordFP = read()
if passwordFP == "ben" then
term.clear()
term.setCursorPos(5,10)
print("Password: "..password)
sleep(5)
register()
else
register()
end
—————————————————————————Thank you for reading this thread, and if you do actually take time looking at it and helping this program, that would mean a lot. If you can't understand what the problem is, I'm very sorry. I'm at a young age.