Posted 21 June 2017 - 05:38 AM
Essentially, I'm trying to incorporate the ability to move the user's cursor back and forth between "User:" and "Pass:" areas of my login page. However i have absolutely no idea or the drive to want to try over and over to accomplish it.
So, here is the code.
So, here is the code.
os.pullEvent = os.pullEventRaw
os.loadAPI("/.LOGIN/.API/modem")
local modem = modem.modSide()
if modem ~= nil then
modem = modem
else
print("No Connection")
sleep(10)
os.reboot()
end
function login()
term.clear()
term.setTextColor(colors.green)
print("Encrypted ")
term.setTextColor(colors.red)
print(" ")
print(" ")
print(" ")
print(" ")
print(" ")
print(" ")
print(" ")
print(" User: ")
print(" Pass: ")
print(" ")
print(" ")
print(" ")
print(" ")
print(" ")
print(" ")
print(" ")
print(" Login v2.0")
User()
end
local function readFile(file)
local f = fs.open(file, "r")
local text = f.readAll()
f.close()
return text
end
local function listen()
rednet.open(modem)
id, message, distance = rednet.receive()
if message == "true" then
return true
elseif message == "false" then
return false
else
return err01
end
end
local function checkCreds(u, p, id, Sid)
Sid = tonumber(Sid)
shell.run("/.LOGIN/.Auth " ..u.. " " ..p.. " " ..id.. " " ..Sid)
if listen() == true then
term.clear()
term.setCursorPos(1,1)
term.setTextColor(colors.white)
print("Welcome " ..u)
else
User("f")
end
end
function User(x)
if x ~= nil then
term.setCursorPos(1,27)
term.clearLine()
term.setCursorPos(30,1)
term.setTextColor(colors.yellow)
write("Incorrect Credentials")
term.setCursorPos(1,9)
term.clearLine()
term.setTextColor(colors.red)
print(" User: ")
term.setCursorPos(1,10)
term.clearLine()
print(" Pass: ")
term.setTextColor(colors.green)
term.setCursorPos(26,9)
write(" ")
u = read()
term.setCursorPos(26,10)
term.setTextColor(colors.green)
write(" ")
p = read("*")
term.setTextColor(colors.red)
Sid = tonumber(readFile("/.LOGIN/.id"))
id = os.getComputerID()
checkCreds(u, p, id, Sid)
term.setCursorPos(1,9)
term.clearLine()
term.setCursorPos(1,10)
term.clearLine()
term.setCursorPos(1,2)
else
term.setCursorPos(1,9)
term.clearLine()
term.setTextColor(colors.red)
print(" User: ")
term.setCursorPos(26,9)
term.setTextColor(colors.green)
write(" ")
-- I thought making a new "read()" function would be the best way to go where it decides if the user has pressed a key or input actual text..
u = read()
term.setCursorPos(1,10)
term.clearLine()
term.setTextColor(colors.red)
print(" Pass: ")
term.setCursorPos(26,10)
term.setTextColor(colors.green)
write(" ")
-- Same here
p = read("*")
Sid = tonumber(readFile("/.LOGIN/.id"))
id = os.getComputerID()
checkCreds(u, p, id, Sid)
term.setCursorPos(1,9)
term.clearLine()
term.setCursorPos(1,10)
term.clearLine()
term.setCursorPos(1,2)
end
end
login()