Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Users = {
- {'VicyX', 'uabitch34'},
- {'test', 'test'}
- }
- local MasterPass = "password"
- local LoginUser
- local LoginPass
- local DoorOpen = false
- --Create Windows
- local winLogin = window.create(term.current(), 1, 1, 50, 30)
- local winMenu = window.create(term.current(), 1, 1, 50, 30)
- winMenu.setVisible(false)
- local winAddUser = window.create(term.current(), 1, 1, 50, 30)
- winAddUser.setVisible(false)
- local winDelUser = window.create(term.current(), 1, 1, 50, 30)
- winDelUser.setVisible(false)
- local winListUsers = window.create(term.current(), 1, 1, 50, 30)
- winListUsers.setVisible(false)
- function printLoginArt()
- print("BITCH INC. PRODUCTS")
- end
- function clearAllWindows()
- winLogin.clear()
- winMenu.clear()
- winAddUser.clear()
- winDelUser.clear()
- winListUsers.clear()
- winLogin.setVisible(false)
- winMenu.setVisible(false)
- winAddUser.setVisible(false)
- winDelUser.setVisible(false)
- winListUsers.setVisible(false)
- end
- function listUsers()
- clearAllWindows()
- winListUsers.setVisible(true)
- winListUsers.clear()
- print('[[USER LIST]')
- print()
- print()
- print('Select a User:')
- print()
- for i,v in pairs(Users) do
- print("["..tostring(i).."] "..v[1])
- end
- print()
- write('Press ENTER to Continue...')
- local resp = read(" ")
- end
- function delUser()
- clearAllWindows()
- winDelUser.setVisible(true)
- winDelUser.clear()
- print('[[DELETE USER]')
- print()
- print()
- print('Select a User:')
- print()
- for i,v in pairs(Users) do
- print("["..tostring(i).."] "..v[1])
- end
- local resp = read()
- if tonumber(resp) then
- if Users[tonumber(resp)] then
- print()
- write(Users[tonumber(resp)][1].." Password OR Master Password: ")
- local inputPass = read("*")
- if inputPass == MasterPass or inputPass == Users[tonumber(resp)][2] then
- winDelUser.setTextColor(colors.green)
- write("Successfully Deleted User")
- winDelUser.setTextColor(colors.white)
- sleep(2)
- if Users[tonumber(resp)][1] == LoginUser then
- table.remove(Users, tonumber(resp))
- return true
- end
- table.remove(Users, tonumber(resp))
- else
- winDelUser.setTextColor(colors.red)
- write("Invalid")
- winDelUser.setTextColor(colors.white)
- sleep(2)
- delUser()
- end
- else
- winDelUser.setTextColor(colors.red)
- write("Invalid")
- winDelUser.setTextColor(colors.white)
- sleep(2)
- delUser()
- end
- end
- end
- function addUser()
- clearAllWindows()
- winAddUser.setVisible(true)
- winAddUser.clear()
- print('[ADD USER]')
- print()
- print()
- write("Current User Password: ")
- local inputCurPass = read("*")
- write("User Name: ")
- local inputUserName = read()
- write("User Password: ")
- local inputUserPass = read("*")
- write("Confirm User Password: ")
- local inputConfUserPass = read("*")
- local Error = false
- if inputCurPass == LoginPass then
- for i,v in pairs(Users) do
- if string.lower(v[1]) == string.lower(inputUserName) then
- Error = true
- end
- end
- if inputUserPass ~= inputConfUserPass then
- Error = true
- end
- end
- if Error == false then
- table.insert(Users, {inputUserName, inputUserPass})
- winAddUser.setTextColor(colors.green)
- write("Successfully added User")
- winAddUser.setTextColor(colors.white)
- sleep(2)
- else
- winAddUser.setTextColor(colors.red)
- write("Invalid")
- winAddUser.setTextColor(colors.white)
- sleep(2)
- addUser()
- end
- end
- function Login()
- clearAllWindows()
- --winLogin.setBackgroundColor(colors.blue)
- winLogin.clear()
- winLogin.setCursorPos(1,1)
- winLogin.setVisible(true)
- winLogin.restoreCursor()
- printLoginArt()
- print()
- print()
- write("Username: ")
- inputUser = read()
- write("Password: ")
- inputPass = read("*")
- local Found = false
- for i,v in pairs(Users) do
- if Found == false and inputUser == v[1] and inputPass == v[2] then
- Found = true
- LoginUser = v[1]
- LoginPass = v[2]
- winLogin.setTextColor(colors.green)
- write("Login Successful")
- winLogin.setTextColor(colors.white)
- sleep(2)
- Menu()
- else
- if Found == False then
- winLogin.setTextColor(colors.red)
- write("Invalid Login")
- winLogin.setTextColor(colors.white)
- sleep(2)
- end
- end
- end
- end
- function Menu()
- clearAllWindows()
- winLogin.setVisible(false)
- local Logout = false
- while Logout == false do
- winMenu.clear()
- winMenu.setVisible(true)
- print('[MENU]')
- print()
- print()
- print("Select an option: ")
- print()
- if redstone.getOutput("right") == false then
- print("[1] Toggle Door [CLOSED]")
- else
- print("[1] Toggle Door [OPEN]")
- end
- print("[2] Create New User")
- print("[3] Delete User")
- print("[4] User List")
- print("[5] Logout")
- print()
- local resp = read()
- if tonumber(resp) then
- if tonumber(resp) == 1 then
- if DoorOpen == false then
- redstone.setOutput('right', true)
- DoorOpen = true
- else
- redstone.setOutput('right', false)
- DoorOpen = false
- end
- elseif tonumber(resp) == 2 then
- addUser()
- elseif tonumber(resp) == 3 then
- local funcResp = delUser()
- if funcResp == true then
- Logout = true
- end
- elseif tonumber(resp) == 4 then
- listUsers()
- elseif tonumber(resp) == 5 then
- LoginUser = nil
- LoginPass = nil
- Logout = true
- end
- end
- end
- end
- while true do
- sleep(.5)
- Login()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement