Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --this is the base menu for my new CC Tweaked OS. this menu only appears when either a crash has happened, actual menu is missing, files corrupted, or a new Boot Update is avaliable
- tArg = {...}
- local w,h = term.getSize()
- local Reason = tArg[1]
- local Page = "Login"
- local User = nil
- local Password = nil
- local Misc1 = nil
- local Misc2 = nil
- function Clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- function CenterText(y,text)
- local x = math.floor((w - string.len(text)) /2)
- term.setCursorPos(x,y)
- term.clearLine()
- term.write(text)
- end
- function SlowCenterText(y,text)
- local x = math.floor((w - string.len(text)) /2)
- term.setCursorPos(x,y)
- term.clearLine()
- textutils.slowWrite(text)
- end
- function GetPageData()
- if Page == "Login" then
- if fs.exists("AccountLogin") == true then
- local file = fs.open("AccountLogin","r")
- User = file.readLine(1)
- Password = file.readLine(2)
- file.close()
- else
- User = "Guest"
- Password = nil
- end
- elseif Page == "Menu" then
- elseif Page == "Update" then
- elseif Page == "Security" then
- end
- end
- function DrawMenu()
- Clear()
- if Page == "Login" then
- term.setBackground(colors.cyan)
- CenterText(1,"----BASE-MENU----")
- CenterText(2,"Login Menu")
- CenterText(3,"PLEASE LOGIN TO MAIN ACCOUNT")
- term.setCursorPos(1,5)
- term.write("Username")
- term.setCursorPos(1,6)
- term.write(User)
- term.setCursorPos(1,7)
- term.write("Password")
- elseif Page == "Menu" then
- term.setBackground(colors.cyan)
- CenterText(1,"---Menu---")
- CenterText(4,"1 - Updates")
- CenterText(6,"2 - Security")
- CenterText(8,"3 - Settings(WIP)")
- CenterText(10,"4 - Restart")
- elseif Page == "Update" then
- elseif Page == "Security" then
- end
- end
- function UserInteraction()
- if Page == "Login" then
- if User == "Guest" or Password == nil then
- term.setCursorPos(1,9)
- term.write("Please Press Enter to Continue")
- repeat
- local event, key = os.pullEvent("key")
- until key == keys.enter
- Clear()
- Page = "Menu"
- GetPageData()
- DrawMenu()
- UserInteraction()
- else
- local input = read()
- term.setCursorPos(1,8)
- while true do
- local event, key = os.pullEvent("key")
- term.write(input)
- if key == keys.enter then
- break
- end
- end
- if input == Password then
- Page = "Menu"
- Clear()
- GetPageData()
- DrawMenu()
- UserInteraction()
- else
- Clear()
- GetPageData()
- DrawMenu()
- UserInteraction()
- end
- end
- elseif Page == "Menu" then
- while true do
- local event, key = os.pullEvent("key")
- if key == keys.one then
- Page = "Update"
- break
- elseif key == keys.two then
- Page = "Security"
- break
- elseif key == keys.three then
- Page = "Settings"
- break
- elseif key == keys.four then
- Page = "Reboot"
- break
- end
- end
- if Page == "Reboot" then
- os.reboot()
- else
- Clear()
- GetPageData()
- DrawMenu()
- UserInteraction()
- end
- elseif Page == "Update" then
- elseif Page == "Security" then
- end
- end
- Clear()
- GetPageData()
- DrawMenu()
- UserInteraction()
Add Comment
Please, Sign In to add comment