Posted 30 April 2014 - 08:53 PM
Hey guys,
I'm pretty new to ComputerCraft and this Forum, and I have started programming with Lua a few weeks before…
I have made a program where you have to put in your username and your password to get into the terminal.
Everything works fine until I get to the part where I have to enter the password <_</>
I have saved the code as the startup so its sort of a password log-in screen when you start the computer.
When I enter it correctly, it says "Hello" and I can acces the terminal, but when I enter it wrong it grants me access to the terminal too. It should actually say "Invalid Password" and then reboot the pc, but it ends the program instead :wacko:/>
Here is the code:
Im pretty sure when the password the user has entered doesn't match with the original one, it should reboot…But it doesnt >.<
Again it just ends the program without outputting any errors.
Anyways,sorry if there is a really big mistake in this code but as I already said, I am new to Lua :P/>
I am trying to run this on my server so It would be awesome if you guys could help me with this!
Greetings
UselessCookie
I'm pretty new to ComputerCraft and this Forum, and I have started programming with Lua a few weeks before…
I have made a program where you have to put in your username and your password to get into the terminal.
Everything works fine until I get to the part where I have to enter the password <_</>
I have saved the code as the startup so its sort of a password log-in screen when you start the computer.
When I enter it correctly, it says "Hello" and I can acces the terminal, but when I enter it wrong it grants me access to the terminal too. It should actually say "Invalid Password" and then reboot the pc, but it ends the program instead :wacko:/>
Here is the code:
print("-----------------------")
print("CCM Computers Inustries")
print("-----------------------")
textutils.slowPrint("Welcome!")
sleep(1)
shell.run("clear")
pass1 = "Test"
pass2 = "Test2" -- This password is not used yet too
user1 = "ZetShock"
user2 = "Mineserver3000" -- This user isn't implemented yet.I want to get the part with user1 done first
print("-----------------------------------")
print("Please enter password and username: ")
print("-----------------------------------")
user = io.read()
if user == user1 then
password = read("*")
if password == pass1 then
textutils.slowPrint("Hello")
sleep(1)
end
shell.run("clear")
else
print("Invalid Password")
shell.run("reboot")
end
Im pretty sure when the password the user has entered doesn't match with the original one, it should reboot…But it doesnt >.<
Again it just ends the program without outputting any errors.
Anyways,sorry if there is a really big mistake in this code but as I already said, I am new to Lua :P/>
I am trying to run this on my server so It would be awesome if you guys could help me with this!
Greetings
UselessCookie