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
table search and location confirm
Started by makerimages, Aug 26 2012 08:48 AM
7 replies to this topic
#1
Posted 26 August 2012 - 08:48 AM
#2
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
Posted 26 August 2012 - 09:20 AM
:C what messed up? as i really need this
#4
Posted 26 August 2012 - 09:23 AM
makerimages, on 26 August 2012 - 09:20 AM, said:
:C what messed up? as i really need this
#5
Posted 26 August 2012 - 09:26 AM
Could anyone help to fix it??
#6
Posted 26 August 2012 - 10:49 AM
take a look at my airlock server programm: http://pastebin.com/DDniwcLY
#7
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
Posted 27 August 2012 - 03:03 PM
makerimages, 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?
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











