Here is the code:
local oldPull = os.pullEvent
os.pullEvent = os.pullEventRaw
-- Above, getting rid of those pesky terminate "hackers" --
-- Below, defining accounts and passwords --
local a = {
a[1]="Brodur",
a[2]="Hard24get"
}
-- I'd like to condense these in the future if possible --
local p = {
p[1]="qwerty25",
p[2]="blackmesa"
}
term.clear()
term.setCursorPos(1,1)
print("Welcome to the MesaNet, running on BroDOS!")
sleep(0.5)
term.setCursorPos(1,3)
print("Username: ")
print("Password: ")
sleep(0.5)
term.setCursorPos(11,3)
input = read() -- Entering username --
if input==a[1] then --Does the account even exist? if so, continue!--
term.setCursorPos(11,4)
elseif input==a[2] then
term.setCursorPos(11,4)
elseif input=="I give up" then -- Self explanatory --
os.reboot()
else
term.clearLine()
print("No such account!")
sleep(1)
shell.run("login")
code = read("*") -- Seeing if accounts and passwords match, if they do, login! --
if code==p[1] and input==a[1] then
print(" ")
print("Welcome "..a[1].."!")
elseif code==p[2] and input==a[2] then
print(" ")
print("Welcome "..a[2].."!")
else
print("Invalid password!")
sleep(1)
shell.run("login")
end
end
os.pullEvent = oldPull -- Resetting pullEvent --
In the above, it intermittenly skips the password phase if I enter Brodur
I have no idea why it is doing this, just that it is. Hard24get
appears to be working fine, which leads me to believe that the issue is in the following code snippets somewhere:
if input==a[1] then --Does the account even exist? if so, continue!--
term.setCursorPos(11,4)
code = read("*") -- Seeing if accounts and passwords match, if they do, login! --
if code==p[1] and input==a[1] then
print(" ")
print("Welcome "..a[1].."!")
Also, while we're at it, is there any way I could condese those two tables to have both password and username in one, and then create a part like this:
if code==p[1] and input==a[1] then
print(" ")
print("Welcome "..a[1].."!")
elseif code==p[2] and input==a[2] then
print(" ")
print("Welcome "..a[2].."!")
that can have an infinite(or high) number of accounts and passwords?Also, pastebin, so you can inspect it on your own console.
–Edit–
Okay, now this is odd. It worked fine before, but now any input that matches a[1,2] or p[1,2] crashes the computer, forcing a shutdown.