Jump to content




table search and location confirm


7 replies to this topic

#1 makerimages

  • Members
  • 236 posts

Posted 26 August 2012 - 08:48 AM

hi, how should i do the following:

user is asked to enter a username and password(DONE)
the username and password are signed to a variable(DONE)


the parts i need help with:

the program should search a table named Usernames for the username var(lets say its called Uname)
and if it finds the Uname valu in the table it would save its location to a variable
and search a table named Passwords for the password var (Pword)
and if it finds that in a table then save its location in a another variable and then compare the two locations and if they Match then program does shell.run("something") if they dont match the user will be shown a error message and the program would start again

#2 sjele

  • Members
  • 334 posts
  • LocationSomewhere on the planet called earth

Posted 26 August 2012 - 09:08 AM

utable = {}
utable[1] = user1 --Username
utable[2] = user2 -- Username
utable[3] = user3  --Username
pwtable={}
pwtable[1] = pw1 --Pw goes here
pwtable[2] = pw2 --Add pw
pwtable[3] = pw3 --This is were you set the password
write("Username: ")
user = read()
term.clear()
term.setCursorPos(1, 1)
write("Password: ")
pw = read()
term.clear()
term.setCursorPos(1, 1)
for k,v in pairs(utable) do
	 if user == utable[v] then
	 u2 = utable[v]
	 break
  end
end
for j, k in pairs(pwtable) do
	 if pw == pwtable[k] then
	 pw2 = pwtable[k]
	 break
  end
end
if pw2 == pwtable[k] and u2 == utable[v] then
shell.run("something")
end

(Tesetd in CC emulator, should work. If not tell me as i made it it up just now)
Nvm this. Something messed up. Allways does sucsess thingy.

#3 makerimages

  • Members
  • 236 posts

Posted 26 August 2012 - 09:20 AM

:C what messed up? as i really need this

#4 sjele

  • Members
  • 334 posts
  • LocationSomewhere on the planet called earth

Posted 26 August 2012 - 09:23 AM

View Postmakerimages, on 26 August 2012 - 09:20 AM, said:

:C what messed up? as i really need this
If the pw and user did not match i still ran the something program i made, something printed sucsess if it was used. And it printed it, even tho i did not have right username / password.

#5 makerimages

  • Members
  • 236 posts

Posted 26 August 2012 - 09:26 AM

Could anyone help to fix it??

#6 Kolpa

  • New Members
  • 260 posts
  • LocationGermany

Posted 26 August 2012 - 10:49 AM

take a look at my airlock server programm: http://pastebin.com/DDniwcLY

#7 makerimages

  • Members
  • 236 posts

Posted 27 August 2012 - 07:45 AM

its not what i want, yours is rednet, mine is supposed to be one computer centered, could anyone come up with a code?

#8 Kolpa

  • New Members
  • 260 posts
  • LocationGermany

Posted 27 August 2012 - 03:03 PM

View Postmakerimages, on 27 August 2012 - 07:45 AM, said:

its not what i want, yours is rednet, mine is supposed to be one computer centered, could anyone come up with a code?
our purpose is to give you an idea of what to do your disability to change my code is not our problem





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users