--Disable the terminating of programs os.pullEvent = os.pullEventRaw -------------------------------------- loginValue = false value = 0 goToRoot = false --Startup Function- function startup() term.clear() term.setCursorPos(1,1) print("Booting System...") while value < 17 do value = value + 1 paintutils.drawPixel(value,2, colors.red) sleep(0) end paintutils.drawLine(1,2,17,2, colors.green) term.setCursorPos(5,2) print("Complete") paintutils.drawPixel(0,0,colors.black) term.setCursorPos(1,4) end --Login Fucntion-- function login() loggedInAs = null if loginValue == false then print("Username:") local username = read() print("Password:") local password = read("*") if username == "Dark" and password == "Dark" then print("Logged in as ", username) loggedInAs = username loginValue = true else print("Invalid password.") sleep(2) startup() end else print("logging in as: " , username) end end ---------------------- -- end of functions -- ---------------------- startup() print("Available actions: terminal, login, logout, root") while goToRoot == false do input = read() if input == "terminal" then print("Enabeling AE Terminal") login() end if input == "login" then login() end if input == "logout" then loginValue = false print("Successfully logged out.") end if input == "root" then if loginValue == false then print("Root access requires you to be logged in.") login() end if loginValue == true then goToRoot = true end end end startup()
How could I improve this code? I am quite sure there are way 'cleaner' and easier ways of doing this. Any suggestions?