40 posts
Posted 01 April 2013 - 04:02 PM
term.clear()
term.setCursorPos(1,1)
print("Login To CraftOS")
term.setCursorPos(1,3)
--Changeable
pass = "user"
write("Username: ")
input = read()
if input == pass then
print("Welcome User")--Changeable
sleep(5)
term.clear()
term.setCursorPos(1,1)
shell.run("shell")
else
print("Wrong Username")
sleep(2)
print("Rebooting In 3")
sleep(1)
print("2")
sleep("1")
print("1")
sleep(1)
os.reboot()
end
Hello This Is A Tutorial Of How To Make A Login Screen
Make Sure You Call It Startup Otherwise you will have to load it or put shell.run("name") in your startup File
2151 posts
Location
Auckland, New Zealand
Posted 01 April 2013 - 04:23 PM
This is good, however, you may want to explain what it is doing and how it works so it is more of a tutorial.
1190 posts
Location
RHIT
Posted 01 April 2013 - 04:24 PM
1) Make sure that you call it "startup" (without capital - Lua is case sensitive).
2) This is not a tutorial. It does not provide the reader with any knowledge. You need to at least comment your code.
3) I would not use this code as a good example of a password protected computer. Sorry if that sounds harsh, but I am being truthful. There is no terminate protection, it uses os.reboot() rather than a simple while loop, the username/password is global meaning that if somebody has already logged in another person can easily view them, and that's neglecting the fact that the password can be seen as it is typed (no masking character). It is my opinion that you should not write a tutorial until you know what you are doing to at least a basic extent: bad coding practices should not be upheld in the tutorial section.
1619 posts
Posted 01 April 2013 - 06:56 PM
4th to last line: sleep("1") should be sleep(1)
8543 posts
Posted 01 April 2013 - 08:27 PM
This is not a tutorial and might even error when getting to the sleep("1") call. Locked.