Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.pullEvent = os.pullEventRaw
- local off = 0
- local tChoices = {}
- tChoices[0] = 'Change User'
- tChoices[1] = 'Change Pass'
- tChoices[2] = 'Use prompt'
- tChoices[3] = 'Log-off'
- local sChoice = "DEBUG"
- local nTermX, nTermY = term.getSize()
- local sSeperator = ("-"):rep(nTermX) -- Create a seperator string with the size of the terminal
- local tActions = {} -- Twin table of tChouices, we'll put functions in here to do stuff.
- function printFrame2()
- sleep(0.1)
- print("+------------------------|----------------------+")
- print("| ___ __ __ / |")
- print("| /___ / | /__ / |")
- print("| /____ /___| ____| / |")
- print("|__________________/ |")
- print("| Welcome "..user.."")
- print("|-----------------| |")
- print("| | |")
- print("|________________/ |")
- print("| |")
- print("| |")
- print("| |")
- print("| |")
- print("| |")
- print("| |")
- print("| |")
- print("| ________|")
- print("| /VER: 5.0|")
- term.setCursorPos(18,5)
- write(" | ///// // // ///// |")
- sleep(0.1)
- print("+------------------------|----------------------+")
- print("| ___ __ __ / |")
- print("| /___ / | /__ / |")
- print("| /____ /___| ____| / ///// ///// ///// |")
- print("|__________________/ // // // // |")
- print("| Welcome "..user.."")
- print("|-----------------| // // // // |")
- print("| | ///// ///// ///// |")
- print("| | _________________ |")
- print("|________________/ /Ehwhat Operating/ |")
- print("| / System / |")
- print("| /________________/ |")
- print("| |")
- print("| |")
- print("| |")
- print("| |")
- print("| ________|")
- print("| /VER: 5.0|")
- term.setCursorPos(18,5)
- write(" | ///// // // ///// |")
- sleep(0.1)
- print("+------------------------|----------------------+")
- print("| ___ __ __ / |")
- print("| /___ / | /__ / |")
- print("| /____ /___| ____| / ///// ///// ///// |")
- print("|__________________/ // // // // |")
- print("| Welcome "..user.."")
- print("|-----------------| // // // // |")
- print("| | ///// ///// ///// |")
- print("| | _________________ |")
- print("| | /Ehwhat Operating/ |")
- print("|________________/ / System / |")
- print("| /________________/ |")
- print("| |")
- print("| |")
- print("| |")
- print("| |")
- print("| ________|")
- print("| /VER: 5.0|")
- term.setCursorPos(18,5)
- write(" | ///// // // ///// |")
- sleep(0.1)
- print("+------------------------|----------------------+")
- print("| ___ __ __ / |")
- print("| /___ / | /__ / |")
- print("| /____ /___| ____| / ///// ///// ///// |")
- print("|__________________/ // // // // |")
- print("| Welcome "..user.."")
- print("|-----------------| // // // // |")
- print("| | ///// ///// ///// |")
- print("| | _________________ |")
- print("| | /Ehwhat Operating/ |")
- print("| | / System / |")
- print("|________________/ /________________/ |")
- print("| |")
- print("| |")
- print("| |")
- print("| |")
- print("| ________|")
- print("| /VER: 5.0|")
- term.setCursorPos(18,5)
- write(" | ///// // // ///// |")
- sleep(0.1)
- print("+------------------------|----------------------+")
- print("| ___ __ __ / |")
- print("| /___ / | /__ / |")
- print("| /____ /___| ____| / ///// ///// ///// |")
- print("|__________________/ // // // // |")
- print("| Welcome "..user.."")
- print("|-----------------| // // // // |")
- print("| | ///// ///// ///// |")
- print("| | _________________ |")
- print("| | /Ehwhat Operating/ |")
- print("| | / System / |")
- print("| | /________________/ |")
- print("|________________/ |")
- print("| |")
- print("| |")
- print("| |")
- print("| ________|")
- print("| /VER: 5.0|")
- term.setCursorPos(18,5)
- write(" | ///// // // ///// |")
- sleep(0.1)
- print("+------------------------|----------------------+")
- print("| ___ __ __ / |")
- print("| /___ / | /__ / |")
- print("| /____ /___| ____| / ///// ///// ///// |")
- print("|__________________/ // // // // |")
- print("| Welcome "..user.."")
- print("|-----------------| // // // // |")
- print("| | ///// ///// ///// |")
- print("| | _________________ |")
- print("| | /Ehwhat Operating/ |")
- print("| | / System / |")
- print("| | /________________/ |")
- print("| | |")
- print("|________________/ |")
- print("| |")
- print("| |")
- print("| ________|")
- print("| /VER: 5.0|")
- term.setCursorPos(18,5)
- write(" | ///// // // ///// |")
- sleep(0.1)
- print("+------------------------|----------------------+")
- print("| ___ __ __ / |")
- print("| /___ / | /__ / |")
- print("| /____ /___| ____| / ///// ///// ///// |")
- print("|__________________/ // // // // |")
- print("| Welcome "..user.."")
- print("|-----------------| // // // // |")
- print("| | ///// ///// ///// |")
- print("| | _________________ |")
- print("| | /Ehwhat Operating/ |")
- print("| | / System / |")
- print("| | /________________/ |")
- print("| | |")
- print("| / |")
- print("|_______________/ |")
- print("| |")
- print("| ________|")
- print("| /VER: 5.0|")
- term.setCursorPos(18,5)
- write(" | ///// // // ///// |")
- sleep(0.1)
- print("+------------------------|----------------------+")
- print("| ___ __ __ / |")
- print("| /___ / | /__ / |")
- print("| /____ /___| ____| / ///// ///// ///// |")
- print("|__________________/ // // // // |")
- print("| Welcome "..user.."")
- print("|-----------------| // // // // |")
- print("| | ///// ///// ///// |")
- print("| | _________________ |")
- print("| | /Ehwhat Operating/ |")
- print("| | / System / |")
- print("| | /________________/ |")
- print("| | |")
- print("| / |")
- print("| / |")
- print("|______________/ |")
- print("| ________|")
- print("| /VER: 5.0|")
- term.setCursorPos(18,5)
- write(" | ///// // // ///// |")
- end
- function printFrame()
- term.setCursorPos(1,1)
- shell.run("clear")
- print("+------------------------|----------------------+")
- print("| ___ __ __ / |")
- print("| /___ / | /__ / |")
- print("| /____ /___| ____| / ///// ///// ///// |")
- print("|__________________/ // // // // |")
- print("| Welcome "..user.."")
- print("|-----------------| // // // // |")
- print("| | ///// ///// ///// |")
- print("| | _________________ |")
- print("| | /Ehwhat Operating/ |")
- print("| | / System / |")
- print("| | /________________/ |")
- print("| | |")
- print("| / |")
- print("| / |")
- print("|______________/ |")
- print("| ________|")
- print("| /VER: 5.0|")
- term.setCursorPos(18,5)
- write(" | ///// // // ///// |")
- sleep(0.1)
- print("+------------------------|----------------------+")
- print("| ___ __ __ / |")
- print("| /___ / | /__ / |")
- print("| /____ /___| ____| / ///// ///// ///// |")
- print("|__________________/ // // // // |")
- print("| Welcome "..user.."")
- print("|-----------------| // // // // |")
- print("| | ///// ///// ///// |")
- print("| | _________________ |")
- print("| | /Ehwhat Operating/ |")
- print("| | / System / |")
- print("| | /________________/ |")
- print("| | |")
- print("| / |")
- print("|_______________/ |")
- print("| |")
- print("| ________|")
- print("| /VER: 5.0|")
- term.setCursorPos(18,5)
- write(" | ///// // // ///// |")
- sleep(0.1)
- print("+------------------------|----------------------+")
- print("| ___ __ __ / |")
- print("| /___ / | /__ / |")
- print("| /____ /___| ____| / ///// ///// ///// |")
- print("|__________________/ // // // // |")
- print("| Welcome "..user.."")
- print("|-----------------| // // // // |")
- print("| | ///// ///// ///// |")
- print("| | _________________ |")
- print("| | /Ehwhat Operating/ |")
- print("| | / System / |")
- print("| | /________________/ |")
- print("| | |")
- print("|________________/ |")
- print("| |")
- print("| |")
- print("| ________|")
- print("| /VER: 5.0|")
- term.setCursorPos(18,5)
- write(" | ///// // // ///// |")
- sleep(0.1)
- print("+------------------------|----------------------+")
- print("| ___ __ __ / |")
- print("| /___ / | /__ / |")
- print("| /____ /___| ____| / ///// ///// ///// |")
- print("|__________________/ // // // // |")
- print("| Welcome "..user.."")
- print("|-----------------| // // // // |")
- print("| | ///// ///// ///// |")
- print("| | _________________ |")
- print("| | /Ehwhat Operating/ |")
- print("| | / System / |")
- print("| | /________________/ |")
- print("|________________/ |")
- print("| |")
- print("| |")
- print("| |")
- print("| ________|")
- print("| /VER: 5.0|")
- term.setCursorPos(18,5)
- write(" | ///// // // ///// |")
- sleep(0.1)
- print("+------------------------|----------------------+")
- print("| ___ __ __ / |")
- print("| /___ / | /__ / |")
- print("| /____ /___| ____| / ///// ///// ///// |")
- print("|__________________/ // // // // |")
- print("| Welcome "..user.."")
- print("|-----------------| // // // // |")
- print("| | ///// ///// ///// |")
- print("| | _________________ |")
- print("| | /Ehwhat Operating/ |")
- print("| | / System / |")
- print("|________________/ /________________/ |")
- print("| |")
- print("| |")
- print("| |")
- print("| |")
- print("| ________|")
- print("| /VER: 5.0|")
- term.setCursorPos(18,5)
- write(" | ///// // // ///// |")
- sleep(0.1)
- print("+------------------------|----------------------+")
- print("| ___ __ __ / |")
- print("| /___ / | /__ / |")
- print("| /____ /___| ____| / ///// ///// ///// |")
- print("|__________________/ // // // // |")
- print("| Welcome "..user.."")
- print("|-----------------| // // // // |")
- print("| | ///// ///// ///// |")
- print("| | _________________ |")
- print("| | /Ehwhat Operating/ |")
- print("|________________/ / System / |")
- print("| /________________/ |")
- print("| |")
- print("| |")
- print("| |")
- print("| |")
- print("| ________|")
- print("| /VER: 5.0|")
- term.setCursorPos(18,5)
- write(" | ///// // // ///// |")
- sleep(0.1)
- print("+------------------------|----------------------+")
- print("| ___ __ __ / |")
- print("| /___ / | /__ / |")
- print("| /____ /___| ____| / ///// ///// ///// |")
- print("|__________________/ // // // // |")
- print("| Welcome "..user.."")
- print("|-----------------| // // // // |")
- print("| | ///// ///// ///// |")
- print("| | _________________ |")
- print("|________________/ /Ehwhat Operating/ |")
- print("| / System / |")
- print("| /________________/ |")
- print("| |")
- print("| |")
- print("| |")
- print("| |")
- print("| ________|")
- print("| /VER: 5.0|")
- term.setCursorPos(18,5)
- write(" | ///// // // ///// |")
- sleep(0.1)
- print("+------------------------|----------------------+")
- print("| ___ __ __ / |")
- print("| /___ / | /__ / |")
- print("| /____ /___| ____| / |")
- print("|__________________/ |")
- print("| Welcome "..user.."")
- print("|-----------------| |")
- print("| "..sChoice.." ")
- print("|________________/ |")
- print("| |")
- print("| |")
- print("| |")
- print("| |")
- print("| |")
- print("| |")
- print("| |")
- print("| ________|")
- print("| /VER: 5.0|")
- term.setCursorPos(18,5)
- write(" | |")
- term.setCursorPos(19,7)
- write("| |")
- end
- os.pullEvent = os.pullEventRaw
- function printFrameLogin()
- term.setCursorPos(1,1)
- term.clear()
- print("+------------------------|----------------------+")
- print("| ___ __ __ / |")
- print("| /___ / | /__ / |")
- print("| /____ /___| ____| / |")
- print("|__________________/ |")
- print("| |")
- print("| |")
- print("| |")
- print("| |")
- print("| |")
- print("| |")
- print("| |")
- print("| |")
- print("| |")
- print("| |")
- print("| |")
- print("| |")
- print("| |")
- end
- tActions[0] = function() -- Stuff a function in here!
- sChoice = "Username Change"
- printFrame()
- term.setCursorPos(23,1)
- write("/ | Enter Username")
- term.setCursorPos(23,2)
- write(" |_______________________")
- term.setCursorPos(23,3)
- write(" | ")
- term.setCursorPos(23,4)
- write(" |-----------------------")
- term.setCursorPos(26,3)
- input = read()
- term.setCursorPos(49,3)
- write("|")
- if input == PVar.user then
- term.setCursorPos(23,5)
- write(" | Enter New Username: ")
- term.setCursorPos(23,6)
- write(" |_______________________")
- term.setCursorPos(23,7)
- write(" | ")
- term.setCursorPos(23,8)
- write(" |-----------------------")
- term.setCursorPos(26,7)
- input = read()
- term.setCursorPos(49,7)
- write("|")
- PVar.user = input
- term.setCursorPos(23,9)
- write(" | ")
- term.setCursorPos(23,9)
- write(" | Username changed! ")
- term.setCursorPos(23,10)
- write(" \\______________________")
- sleep(1.5)
- printFrame2()
- else
- term.setCursorPos(23,5)
- write(" | Incorrect ")
- term.setCursorPos(22,6)
- write(" \\______________________")
- term.setCursorPos(49,6)
- write("|")
- sleep(1.5)
- printFrame2()
- end
- end
- tActions[1] = function()
- sChoice = "Password Change"
- printFrame()
- term.setCursorPos(23,1)
- write("/ | Enter Password")
- term.setCursorPos(23,2)
- write(" |_______________________")
- term.setCursorPos(23,3)
- write(" | ")
- term.setCursorPos(23,4)
- write(" |-----------------------")
- term.setCursorPos(26,3)
- input = read("*")
- term.setCursorPos(49,3)
- write("|")
- if input == PVar.pass then
- term.setCursorPos(23,5)
- write(" | Enter New Password: ")
- term.setCursorPos(23,6)
- write(" |_______________________")
- term.setCursorPos(23,7)
- write(" | ")
- term.setCursorPos(23,8)
- write(" |-----------------------")
- term.setCursorPos(26,7)
- input = read("*")
- term.setCursorPos(49,7)
- write("|")
- PVar.pass = input
- term.setCursorPos(23,9)
- write(" | Password changed! ")
- term.setCursorPos(23,10)
- write(" \\______________________")
- sleep(1.5)
- printFrame2()
- else
- term.setCursorPos(23,5)
- write(" | Incorrect ")
- term.setCursorPos(22,6)
- write(" \\______________________")
- term.setCursorPos(49,6)
- write("|")
- sleep(1.5)
- printFrame2()
- end
- end
- tActions[2] = function()
- off = 1
- term.clear()
- term.setCursorPos(1,1)
- print("_________________________________________")
- print("| | E.OS V5.0 | Welcome "..PVar.user.."")
- print("|______________________________________/ ")
- term.setCursorPos(41,2)
- write("/")
- term.setCursorPos(1,4)
- end
- tActions[3] = function()
- sChoice = "Log off"
- printFrame()
- term.setCursorPos(22,2)
- write(" \\______________________")
- term.setCursorPos(23,1)
- write(" | Logging off ")
- sleep(0.3)
- term.setCursorPos(23,1)
- write(" | Logging off. ")
- sleep(0.3)
- term.setCursorPos(23,1)
- write(" | Logging off.. ")
- sleep(0.3)
- term.setCursorPos(23,1)
- write(" | Logging off... ")
- term.setCursorPos(49,2)
- write("|")
- sleep(1.5)
- os.reboot()
- end
- -- Finsh above for functions
- local nSelection = 0 -- The current selection defaults at 0
- printFrame2()
- repeat
- term.setCursorPos(1, 1)
- term.clear()
- print("+------------------------|----------------------+")
- print("| ___ __ __ / |")
- print("| /___ / | /__ / |")
- print("| /____ /___| ____| / ///// ///// ///// |")
- print("|__________________/ // // // // |")
- print("| Welcome "..user.."")
- print("|-----------------| // // // // |")
- print("| | ///// ///// ///// |")
- print("| | _________________ |")
- print("| | /Ehwhat Operating/ |")
- print("| | / System / |")
- print("| | /________________/ |")
- print("| | |")
- print("| / |")
- print("| / |")
- print("|______________/ |")
- print("| ________|")
- print("| /VER: 5.0|")
- term.setCursorPos(18,5)
- write(" | ///// // // ///// |")
- term.setCursorPos(2,7)
- for nLine = 0, #tChoices do -- Iterate through the possible options, and print them, marking the chosen one
- local oldx, oldy = term.getCursorPos()
- local sLine = " "
- if nSelection == nLine then
- sLine = ">"
- end
- local sLineNum = tostring(nLine)
- if #sLineNum < 2 then
- sLineNum = "0" .. sLineNum -- Prepend a 0 if it's too short
- end
- sLine = sLine .. "-" .. " " .. tChoices[nLine] -- Construct the string we're printing
- print(sLine) -- Print it#]
- term.setCursorPos(2,oldy+1)
- end
- -- os.pullEvent keys: up - 200, down - 208, enter - 28
- local sEvent, nKey = os.pullEvent("key") -- Using the 1.3 filtering; this will mean only "key" events will pass
- if nKey == 200 or nKey == 17 then -- Up/w key: move up the menu
- if tChoices[nSelection - 1] then -- Check if we can move up
- nSelection = nSelection - 1
- end
- -- Ignore it otherwise
- elseif nKey == 208 or nKey == 31 then -- Down/s key: move down the menu
- if tChoices[nSelection + 1] then -- Check if we can move down
- nSelection = nSelection + 1
- end
- elseif nKey == 28 then -- Enter key: Selecting a choice
- if tActions[nSelection] then
- tActions[nSelection]() -- Run the function associated with the action.
- else
- print("Error: Selection out of bounds: ", nSelection)
- sleep(2)
- shell.run("startup") -- This error is recoverable.
- end
- end
- until off == 1
Add Comment
Please, Sign In to add comment