Posted 24 May 2012 - 03:50 AM
I'd like to make login thing like Windows for ComputerCraft computer
but i no how to do any coding for this
but i no how to do any coding for this
input = read() --Store your input for later
if input == "Hi" then --If you type "Hi" then do this...
print("Hello!")
else -- If you typed something else
os.reboot()
end
Note that you have to give the file the name startup if you want to make it start when you start your computer. Otherwise you'll be able to just reboot the computer, and then access everything. If you really want a username and password, and multiple accounts, it's a bit harder. You'll have to use tables. For example, you could useTo get user input, use read(). read() returns a string so you can do this:input = read() --Store your input for later if input == "Hi" then --If you type "Hi" then do this... print("Hello!") else -- If you typed something else os.reboot() end
usertable = {072608="ComputerOwner", ComputerCraftFan11="Pro Coder", Lolgast ="Clueless"} -- A table with usernames and passwords. EDIT: Your username may not begin with a digit. It will throw an error.
print("Username:") -- Make it ask for a username
username = read() -- Input your username
print("Password:") -- Ask for your password
password = read() -- Input password
if usertable[username] == password then -- Checks if the correct password is filled in
print("Logged in as " .. username)
else
print("Wrong username or password")
sleep(2)
os.reboot() -- restarts computer, if you call this file startup it will start the program again.
end
status,text=pcall(read)
status will return false if it was ctrl t'dill give it a try :)/>/>Take a look at my login script and API located here http://www.computerc...ionupdated-v11/
You can use the API to make your own login script using the API's function which include multiple user support, permissions(admin, user), and the ability to create new accounts.