51 posts
Location
England
Posted 06 April 2012 - 05:07 PM
I know it's very simple so please don't comment saying so, I am a not very good at lua and this is the first working program i have made.
The code:
Spoiler
local oldPull = os.pullEvent;
os.pullEvent = os.pullEventRaw;
function MyOs()
term.clear()
term.setCursorPos(1,1)
print("------------------------------------------------------------------------------------------")
print(" MyOS v 1.1")
print("------------------------------------------------------------------------------------------")
print(" ")
end
user = "sabian"
pass = "cheese"
repeat
MyOs()
write "Enter username: "
un = read()
print(" ")
write"Enter password: "
pw = read("*")
print(" ")
if un == user and pw == pass then
MyOs()
textutils.slowPrint "Access Granted!"
print(" ")
end
until un == user and pw == pass
864 posts
Location
Sometime.
Posted 06 April 2012 - 08:55 PM
So.. MyOS?
A CC OS??
Or just a login?
53 posts
Posted 06 April 2012 - 08:57 PM
Nice. Challenge: add an ability to register multiple users with tables.
58 posts
Location
Mars
Posted 06 April 2012 - 09:54 PM
Little hint… you wanted to make a new line by putting
print(" ")
Instead of doing that you can take that print out and write this in the enter password thing:
write("\nEnter password: ")
Putting \n in a string makes a new line, that that makes a new line AND THEN types new password.
864 posts
Location
Sometime.
Posted 06 April 2012 - 10:59 PM
@EatenAlive3
That would be cool, databases.
51 posts
Location
England
Posted 07 April 2012 - 12:15 PM
So.. MyOS?
A CC OS??
Or just a login?
it's just a password program, I might make it into an OS though.
51 posts
Location
England
Posted 07 April 2012 - 12:18 PM
Little hint… you wanted to make a new line by putting
print(" ")
Instead of doing that you can take that print out and write this in the enter password thing:
write("nEnter password: ")
Putting n in a string makes a new line, that that makes a new line AND THEN types new password.
So if I put that would it leave a line out and then put the text or would it just put the text on the new line?
@EatenAlive3 I don't really understand tables in computercraft, thanks for the suggestion though.
864 posts
Location
Sometime.
Posted 07 April 2012 - 02:36 PM
Tables.. Like databases
51 posts
Location
England
Posted 07 April 2012 - 02:54 PM
Tables.. Like databases
I meant i don't know how to use them.
58 posts
Location
Mars
Posted 07 April 2012 - 03:59 PM
Little hint… you wanted to make a new line by putting
print(" ")
Instead of doing that you can take that print out and write this in the enter password thing:
write("nEnter password: ")
Putting n in a string makes a new line, that that makes a new line AND THEN types new password.
So if I put that would it leave a line out and then put the text or would it just put the text on the new line?
@EatenAlive3 I don't really understand tables in computercraft, thanks for the suggestion though.
It will put a new line then write on the new line but since you used wire and not print the password will enter and te same line, the console will look like this:
Enter username: admin
Enter password: pass
53 posts
Posted 07 April 2012 - 11:01 PM
You really should learn to use tables, or else when you start to do complex things, you are going to have a
lot of trouble.
http://lua-users.org/wiki/TablesTutorial
51 posts
Location
England
Posted 09 April 2012 - 02:14 PM
You really should learn to use tables, or else when you start to do complex things, you are going to have a
lot of trouble.
http://lua-users.org.../TablesTutorial
Thanks :P/>/> , but i still find tables very confusing.