This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
dextermb's profile picture

How to write to a Var

Started by dextermb, 12 December 2012 - 10:02 AM
dextermb #1
Posted 12 December 2012 - 11:02 AM
I'd like to be able to edit the password by a command… here is what i have so far…


function reboot()
print ("Incorrect Username and/or Password")
  sleep(1)
   os.reboot()
end
Username1 = "Dexter"
Password1 = "dexter"
Username2 = "Cory"
Password2 = "cory"
Username3 = "Brandy"
Password3 = "brandy"
wording1 = "pwdchange"
shell.run("clear")
os.pullEvent = os.pullEventRaw
  shell.run("titlescreen")
   sleep(2)
    shell.run("clear")
  write ("Username: ")
   input = read()
    if input == Username1 then
	 elseif input == Username2 then
	 elseif input == Username3 then
  write ("Password: ")
   input = read("*")
    and input == Password1
	 and input == Password2
	 and input == Password3
    sleep(0.5)
  print ("Access Granted")
   shell.run("clear")
  print [[
----------
| DC API |
----------]]
   else
    reboot()

[b]  input = read()
   if input == wording1 then
  write ("Username: ")
   if input == Username1 then
    write ("Old Password: ")
    and input == Password1
	 write ("New Password: ")
	  input = read()[/b]
	  
 
end
end


I need help with the pwdchange part…

  input = read()
   if input == wording1 then
  write ("Username: ")
   if input == Username1 then
    write ("Old Password: ")
    and input == Password1
	 write ("New Password: ")
	  input = read()
	 

end
NOTE: This isn't finished, posting halfway through the development ^^
OmegaVest #2
Posted 12 December 2012 - 11:08 AM
This needs tables. And it will get a lot more complicated once you add them.

Basically, what you're gonna have to do (and I'm sorry I can't do it for you, but it took me hours of work to get mine right, and I don't really fancy doing that for the benefit of someone else right now), is you're gonna need to store your username/password combinations in 1 or 2 separate files, have them read in to a table labelled users, or two tables labelled users and passwords respectively, and then have the program check user[x] and password[x] when they log in, and when they want to change it, change the password in the program, and send it back to the files when you are done.

And that is seriously complicated, and if you can follow my rambling dialect, good on you, and get coding. Otherwise. . . . You might have to ask for help from others, who will undoubtedly chime in shortly.
dextermb #3
Posted 12 December 2012 - 11:24 AM
This needs tables. And it will get a lot more complicated once you add them.

Basically, what you're gonna have to do (and I'm sorry I can't do it for you, but it took me hours of work to get mine right, and I don't really fancy doing that for the benefit of someone else right now), is you're gonna need to store your username/password combinations in 1 or 2 separate files, have them read in to a table labelled users, or two tables labelled users and passwords respectively, and then have the program check user[x] and password[x] when they log in, and when they want to change it, change the password in the program, and send it back to the files when you are done.

And that is seriously complicated, and if you can follow my rambling dialect, good on you, and get coding. Otherwise. . . . You might have to ask for help from others, who will undoubtedly chime in shortly.

Alright, thanks for that anyways :P/> I'll do some Lua studying i guess :P/>