Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Variables--
- User = nil
- Pass = nil
- A = nil
- Init = nil
- local function Reset()
- shell.run("clear")
- term.setBackgroundColor(colors.blue)
- term.clear()
- term.setTextColor(colors.white)
- textutils.slowPrint("Banking System")
- end
- local function Login()
- term.setCursorPos(10 , 10)
- print("Username:")
- term.setCursorPos(10 , 11)
- print("Password:")
- term.setCursorPos(20 , 10)
- User = read()
- term.setCursorPos(20 , 11)
- Pass = read("*")
- end
- local function Check()
- if fs.exists("disk/Users/"..User) == true then
- h = fs.open("disk/Users/"..User, "r")
- A = h.readAll() else
- Reset()
- term.setCursorPos(10 , 10)
- textutils.slowPrint("User does not exist")
- sleep(3)
- term.setCursorPos(10 , 10)
- term.clearLine()
- Login()
- end
- end
- local function Verify()
- if A == Pass then
- Reset()
- term.setCursorPos(45 , 1)
- term.setTextColor(colors.green)
- print(""..User)
- term.setBackgroundColor(colors.blue)
- term.setTextColor(colors.white)
- term.setCursorPos(10 , 10) else
- Reset()
- term.setCursorPos(10 , 10)
- textutils.slowPrint("Incorrect password")
- sleep(2)
- term.setCursorPos(10 , 10)
- term.clearLine()
- shell.run("disk/Client.lua")
- end
- end
- local function Initialize()
- local h = fs.open("disk/Init.lua", "r")
- Init = h.readAll()
- h.close()
- if Init == "true" then
- term.setCursorPos(1 , 8)
- textutils.slowPrint("Enter new credentials")
- sleep(2)
- Login()
- if fs.exists("disk/Users/"..User) == true then
- Reset()
- term.setCursorPos(10 , 10)
- textutils.slowPrint("Invalid Username")
- sleep(2)
- Reset()
- Initialize() else
- h = fs.open("disk/Users/"..User , "w")
- h.writeLine(""..Pass)
- h.close()
- Reset()
- term.setCursorPos(7 ,10)
- textutils.slowPrint("Computer will reboot to load credentials")
- sleep(3)
- fs.delete("disk/Init.lua")
- local h = fs.open("disk/Init.lua" , "w")
- h.writeLine("false")
- shell.run("reboot")
- end
- end
- end
- Reset()
- Initialize()
- Login()
- Check()
- Verify()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement