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

Help me. Whats Wrong To This Code.

Started by jumpingjoran, 03 January 2013 - 06:21 AM
jumpingjoran #1
Posted 03 January 2013 - 07:21 AM
Hello,

i just make a cool code for a login system.
i know the basics of computercraft but i dont know whats wrong to my code.

what i did wanted to make:
a login system that can have more login accounts.

what i want to add later:
that there are premissions for the accounts that when there is a admin logged in he can do everything. a vip or something can make programs but can not edit the standard programs. and default people can only login and run the programs but can not edit them. is this possible?
and that people can registrate as new user with default premissions.

now whats wrong with my code:
the first login is working (admin) but when i try my account ( jumpingjoran ) it says:
Username and Password do not match

and the loading thing is not working…


please can anybody help me? i just want my login system done.
i post my code on pastebin:
http://pastebin.com/RkZrJDef

and i post my code here too but i dont know if its working:

Spoiler

os.pullEvent = os.pullEventRaw
term.clear()
term.setCursorPos(1,1)
print ("			  __ |  __ |			Login System  ")
print ("				||	||	_ \\ (_-<			 ")
print ("			  __//  __// .\\___/ ___/			 ")
print ("------------------(Version: 2.1)------------------")
print ("")
print ("Login: ")
print ("")

-- admin account

write ("Username: ")
username = read()
if username == "admin" then
sleep(0.5)
write ("Password: ")
  password = read ("*")
  if password == "admin" then	
  sleep(1)

  function line()
term.setCursorPos(17,11)
term.clearLine()
end
line()
print ("[	Loading	]")
sleep(0,5)
line()
print ("[  Loading 16%  ]")
line()
sleep(0,5)
print ("[  Loading 31%  ]")
line()
sleep(0,5)
print ("[  Loading 46%  ]")
line()
sleep(0,5)
print ("[  Loading 62%  ]")
line()
sleep(0,5)
print ("[  Loading 78%  ]")
line()
sleep(0,5)
print ("[  Loading 93%  ]")
line()
sleep(0,5)
print ("[  Loading Done ]")
line()
sleep(0,5)
print ("Account Accepted.")
sleep(3)


term.clear()
term.setCursorPos(1,1)
print ("			  __ |  __ |   Welcome, "..username.."")
print ("				||	||	_ \\ (_-<			 ")
print ("			  __//  __// .\\___/ ___/			 ")
print ("-----------------(Version: 2.1)-------------------")
print ("")
sleep(0.5)


else
line()
print ("[	Loading	]")
sleep(0,5)
line()
print ("[  Loading 16%  ]")
line()
sleep(0,5)
print ("[  Loading 31%  ]")
line()
sleep(0,5)
print ("[  Loading 46%  ]")
line()
sleep(0,5)
print ("[  Loading 62%  ]")
line()
sleep(0,5)
print ("[  Loading 78%  ]")
line()
sleep(0,5)
print ("[  Loading 93%  ]")
line()
sleep(0,5)
print ("[  Loading Done ]")
line()
sleep(0,5)
term.setCursorPos(11,11)
textutils.slowPrint ("Username or Password is not Registered")
sleep(3)
os.reboot()
end


-- jumpingjoran account

elseif username == "jumpingjoran" then
sleep(0.5)
  if password == "jumpingjoran" then
  sleep(1)

  function line()
term.setCursorPos(17,11)
term.clearLine()
end
line()
print ("[	Loading	]")
sleep(0,5)
line()
print ("[  Loading 16%  ]")
line()
sleep(0,5)
print ("[  Loading 31%  ]")
line()
sleep(0,5)
print ("[  Loading 46%  ]")
line()
sleep(0,5)
print ("[  Loading 62%  ]")
line()
sleep(0,5)
print ("[  Loading 78%  ]")
line()
sleep(0,5)
print ("[  Loading 93%  ]")
line()
sleep(0,5)
print ("[  Loading Done ]")
line()
sleep(1)
print ("Account Accepted.")
sleep(3)


term.clear()
term.setCursorPos(1,1)
print ("			  __ |  __ |   Welcome, "..username.."")
print ("				||	||	_ \\ (_-<			 ")
print ("			  __//  __// .\\___/ ___/			 ")
print ("-----------------(Version: 2.1)-------------------")
print ("")
sleep(0.5)


else
line()
print ("[	Loading	]")
sleep(0,5)
line()
print ("[  Loading 16%  ]")
line()
sleep(0,5)
print ("[  Loading 31%  ]")
line()
sleep(0,5)
print ("[  Loading 46%  ]")
line()
sleep(0,5)
print ("[  Loading 62%  ]")
line()
sleep(0,5)
print ("[  Loading 78%  ]")
line()
sleep(0,5)
print ("[  Loading 93%  ]")
line()
sleep(0,5)
print ("[  Loading Done ]")
line()
sleep(0,5)
term.setCursorPos(11,11)
textutils.slowPrint ("Username and Password do not match.")
sleep(3)
os.reboot()
end


-- mastermy2 account

elseif username == "mastermy2" then
sleep(0.5)
  if password == "mastermy2" then
  sleep(1)

  function line()
term.setCursorPos(17,11)
term.clearLine()
end
line()
print ("[	Loading	]")
sleep(0,5)
line()
print ("[  Loading 16%  ]")
line()
sleep(0,5)
print ("[  Loading 31%  ]")
line()
sleep(0,5)
print ("[  Loading 46%  ]")
line()
sleep(0,5)
print ("[  Loading 62%  ]")
line()
sleep(0,5)
print ("[  Loading 78%  ]")
line()
sleep(0,5)
print ("[  Loading 93%  ]")
line()
sleep(0,5)
print ("[  Loading Done ]")
line()
sleep(1)
print ("Account Accepted.")
sleep(3)


term.clear()
term.setCursorPos(1,1)
print ("			  __ |  __ |   Welcome, "..username.."")
print ("				||	||	_ \\ (_-<			 ")
print ("			  __//  __// .\\___/ ___/			 ")
print ("-----------------(Version: 2.1)-------------------")
print ("")
sleep(0.5)


else
line()
print ("[	Loading	]")
sleep(0,5)
line()
print ("[  Loading 16%  ]")
line()
sleep(0,5)
print ("[  Loading 31%  ]")
line()
sleep(0,5)
print ("[  Loading 46%  ]")
line()
sleep(0,5)
print ("[  Loading 62%  ]")
line()
sleep(0,5)
print ("[  Loading 78%  ]")
line()
sleep(0,5)
print ("[  Loading 93%  ]")
line()
sleep(0,5)
print ("[  Loading Done ]")
line()
sleep(0,5)
term.setCursorPos(11,11)
textutils.slowPrint ("Username and Password do not match.")
sleep(3)
os.reboot()
end



else
sleep(1)
print ("Username not found.")
sleep(3)
os.reboot()
end

[Added code tags. -L]
Lyqyd #2
Posted 03 January 2013 - 07:30 AM
You aren't read()ing the password for any of the accounts except the admin account.
remiX #3
Posted 03 January 2013 - 07:32 AM
Very difficult to read because of the lack of indentation but for the loading, use a function (add it to the line function) instead of writing it the whole time.
sleep(0.5) use fullstops, not commas.

As for why your account isn't working, I'm busy adding some indentation and I'll check it why, you might have put it in the wrong block.
jumpingjoran #4
Posted 03 January 2013 - 07:58 AM
ok thnx for the help for so far! but i think that i cant make it..
so u are checking it and make it work? if thats a yes pleas post it for me that whould be great!