Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[AceyoOS 2.0 done by aceyo369]]--
- --[[Inspired by Nitrogen Fingers]]--
- --[[ Side functions ]]--
- local w, h = term.getSize()
- local select = 1
- local nF = true
- local function clear()
- term.clear()
- term.setCursorPos(1, 1)
- end
- local function printCentered(msg, ypos)
- term.setCursorPos(w/2 - #msg/2, ypos)
- term.write(msg)
- end
- local function printAcross(bar,ypos)
- for i = 1, w-1 do
- term.setCursorPos(i, ypos)
- term.write(bar)
- end
- end
- local function printLeft(msg, ypos)
- term.setCursorPos(3, ypos)
- term.write(msg)
- end
- local function printBottom(msg)
- term.setCursorPos(w/2 - #msg/2, h - 1)
- term.write(msg)
- end
- local function printRight(msg)
- term.setCursorPos(w/2 - 3, h/2 + 1)
- term.write(msg)
- end
- local function printMiddle(msg, xpos)
- term.setCursorPos(xpos, h/2)
- term.write(msg)
- end
- local function printBotline()
- printAcross("-", h - 2)
- end
- --[[ Main Desktop ]]--
- runningTime = os.time()
- mm = "Ace_Desktop"
- local title = mm
- local pID = os.getComputerID()
- local user = "Anon"
- local function printHeader()
- print("AceyoOS 1.0")
- printCentered(title,1)
- term.setCursorPos(1,2)
- term.write("Time: "..textutils.formatTime(runningTime,false))
- term.setCursorPos(w - 20, 2)
- print("Desktop_User:"..user)
- term.setCursorPos(w - 5, 1)
- print("ID: "..pID) term.setCursorPos(w - 20, 2)
- printAcross("-", 3)
- printBotline()
- end
- --[[Extra loading screen]]--
- local function runningPercent()
- clear()
- printHeader()
- printCentered("Loading...", h/2)
- for i = 0, 100 do
- term.setCursorPos(1, h/2 + 1)
- term.clearLine()
- printCentered(i.."%", h/2 + 1)
- sleep(0.001)
- end
- term.setCursorPos(1, h/2 + 1)
- term.clearLine()
- printCentered("100%", h/2 + 1)
- sleep(0.5)
- clear()
- printHeader()
- printCentered("Loading Complete", h/2)
- sleep(2)
- clear()
- end
- --[[All Menus with inputs]]--
- local function printMain()
- if select == 1 then
- printCentered("[".."Computer List".."]", 4)
- printBottom("**Locate Computer IDs**")
- else printCentered("Computer List", 4) end
- if select == 2 then
- printCentered("[".."Command".."]", 6)
- printBottom("**Command Wireless Computers**")
- else printCentered("Command", 6) end
- if select == 3 then
- printCentered("[".."Simple Math".."]", 8)
- printBottom("**Solve Mathematics here**")
- else printCentered("Simple Math", 8) end
- if select == 4 then
- printCentered("[".."Games".."]", 10)
- printBottom("**Play available games here**")
- else printCentered("Games", 10) end
- if select == 5 then
- printCentered("[".."Programs".."]", 12)
- printBottom("**Edit and Run Computer Programs**")
- else printCentered("Programs", 12) end
- if select == 6 then
- printCentered("[".."Options".."]", 14)
- printBottom("**Change Setting**")
- else printCentered("Options", 14) end
- if select == 7 then
- printCentered("[".."Exit".."]", 16)
- printBottom("**Terminate the AceyoOS 1.0**")
- else printCentered("Exit", 16) end
- end
- local function inputMain()
- event, key = os.pullEvent("key")
- if key == 200 and select > 1 then
- select = select - 1
- end
- if key == 208 and select < 7 then
- select = select + 1
- end
- if key == 28 and select == 1 then
- title = "Computer_List"
- changeState("Computer_List")
- end
- if key == 28 and select == 2 then
- title = "Command"
- changeState("Command")
- end
- if key == 28 and select == 3 then
- title = "Simple_Math"
- changeState("Simple_Math")
- end
- if key == 28 and select == 4 then
- title = "Games"
- changeState("Games")
- end
- if key == 28 and select == 5 then
- title = "Program_System"
- changeState("Programs")
- end
- if key == 28 and select == 6 then
- title = "Options"
- changeState("Options")
- end
- if key == 28 and select == 7 then
- clear()
- nF = false
- end
- end
- local function printList()
- printCentered("No recorded Computer", h/2)
- printCentered("Press backspace", h/2 + 2)
- printCentered("to return to main menu", h/2 + 3)
- end
- local function inputList()
- event, key = os.pullEvent("key")
- if key == keys.backspace then
- title = mm
- changeState("main")
- end
- end
- local function printCommand()
- rednet.open("bottom")
- printCentered("Select Computer ID: ", h/2)
- CompID = tonumber(read())
- clear()
- printHeader()
- printCentered("Command for computer: ", h/2)
- cmd = read()
- clear()
- printHeader()
- end
- local sendmsg = "Sending..."
- local function inputCommand()
- term.setCursorPos(w/2 - #sendmsg/2, h/2)
- textutils.slowPrint(sendmsg)
- rednet.send(CompID, cmd)
- sleep(1)
- clear()
- printHeader()
- printCentered("Command Sent", h/2)
- sleep(1)
- rednet.close("bottom")
- title = mm
- changeState("main")
- end
- local function printGames()
- if select == 1 then
- printCentered("[".."Snake Game".."]", 7)
- printBottom("**Play a classical Snakes**")
- else printCentered("Snake Game", 7) end
- if select == 2 then
- printCentered("[".."T3".."]", 9)
- printBottom("**Play TicTacToe**")
- else printCentered("T3", 9) end
- if select == 3 then
- printCentered("[".."Back to Main Menu".."]", 11)
- printBottom("**To Main Menu**")
- else printCentered("Back to Main Menu", 11) end
- end
- local function inputGames()
- event, key = os.pullEvent("key")
- if key == 200 and select > 1 then
- select = select - 1
- elseif key == 208 and select < 3 then
- select = select + 1
- elseif key == 28 and select == 1 then
- runningPercent()
- shell.run("worm")
- nF = false
- elseif key == 28 and select == 2 then
- runningPercent()
- shell.run("t3")
- nF = false
- elseif key == 28 and select == 3 then
- title = mm
- changeState("main")
- end
- end
- local function printMath()
- printCentered("Insert your first number: ", h/2)
- first = tonumber(read())
- clear()
- printHeader()
- printCentered("<+,-,*,/>", h/2 - 1)
- printCentered("Insert your sign: ", h/2)
- sign = read()
- clear()
- printHeader()
- end
- local function inputMath()
- printCentered("Insert your second number: ", h/2)
- second = tonumber(read())
- clear()
- printHeader()
- if sign == "+" then
- total = first + second
- elseif sign == "-" then
- total = first - second
- elseif sign == "*" then
- total = first * second
- elseif sign == "/" then
- total = first / second
- end
- printCentered("Solution: "..total, h/2)
- printCentered("Press any key to go to Main Menu", h/2 + 2)
- event, key = os.pullEvent()
- title = mm
- changeState("main")
- end
- local function printprog()
- if select == 1 then
- printCentered("[".."Run a program".."]", 5)
- printBottom("**Program can be from computer or disk**")
- else printCentered("Run a program", 5) end
- if select == 2 then
- printCentered("[".."Edit a program".."]", 7)
- printBottom("**Able to edit and create script**")
- else printCentered("Edit a program", 7) end
- if select == 3 then
- printCentered("[".."Create a program".."]", 9)
- printBottom("**Make your own program**")
- else printCentered("Create a program", 9) end
- if select == 4 then
- printCentered("[".."Back to Main Menu".."]", 11)
- printBottom("**To Main Menu**")
- else printCentered("Back to Main Menu", 11) end
- end
- local function inputprog()
- event, key = os.pullEvent("key")
- if key == 200 and select > 1 then
- select = select - 1
- elseif key == 208 and select < 4 then
- select = select + 1
- end
- if key == 28 and select == 1 then
- clear()
- printHeader()
- term.setCursorPos(1, h/2)
- shell.run("dir")
- sleep(3)
- clear()
- printHeader()
- printCentered("Program to run: ", h/2)
- prog = read()
- if fs.exists(prog) == true then
- changeState("main")
- title = mm
- clear()
- shell.run(prog)
- else
- clear()
- printHeader()
- printCentered("No Such Program", h/2)
- sleep(1)
- changeState("Programs")
- end
- elseif key == 28 and select == 2 then
- clear()
- printHeader()
- term.setCursorPos(1, h/2)
- shell.run("dir")
- sleep(3)
- clear()
- printHeader()
- printCentered("Which program to edit?", h/2)
- term.setCursorPos(w/2 - 6, h/2 + 1)
- prog = read()
- shell.run("edit",prog)
- elseif key == 28 and select == 3 then
- clear()
- printHeader()
- printCentered("Name of your program: ", h/2)
- term.setCursorPos(w/2 - 6, h/2 + 1)
- prog = read()
- shell.run("edit",prog)
- elseif key == 28 and select == 4 then
- title = mm
- changeState("main")
- end
- end
- local function printOp()
- if select == 1 then
- printCentered("[".."Refresh Time".."]", h/2 - 1)
- printBottom("**See Current Time**")
- else printCentered("Refresh Time", h/2 - 1) end
- if select == 2 then
- printCentered("[".."Password".."]", h/2 + 1)
- printBottom("**Password Setting**")
- else printCentered("Password", h/2 + 1) end
- if select == 3 then
- printCentered("[".."Back to Main Menu".."]", h/2 + 3)
- printBottom("**To Main Menu**")
- else printCentered("Back to Main Menu", h/2 + 3) end
- end
- local function inputOp()
- event, key = os.pullEvent("key")
- if key == 200 and select > 1 then
- select = select - 1
- elseif key == 208 and select < 3 then
- select = select + 1
- elseif key == 28 and select == 1 then
- os.reboot()
- elseif key == 28 and select == 2 then
- title = "Password_Setting"
- changeState("Password")
- elseif key == 28 and select == 3 then
- title = mm
- changeState("main")
- end
- end
- local function printpwR()
- printCentered("Your Username: ", h/2 - 1)
- printCentered("Your Password: ", h/2)
- end
- local function inputpwR()
- term.setCursorPos(w/2 + 8, h/2 - 1)
- inputuser = read()
- term.setCursorPos(w/2 + 8, h/2)
- inputpw = read("*")
- if fs.exists("/user/"..inputuser) then
- clear()
- printHeader()
- printCentered("Account already exists", h/2)
- sleep(1.5)
- else
- fs.makeDir("/user/"..inputuser.."/"..inputpw)
- clear()
- printHeader()
- printCentered("Registration Complete", h/2)
- sleep(1)
- title = mm
- changeState("main")
- end
- end
- local function printpwL()
- printCentered("Your Username: ", h/2 - 1)
- printCentered("Your Password: ", h/2)
- end
- local function inputpwL()
- term.setCursorPos(w/2 + 8, h/2 - 1)
- inputuser = read()
- term.setCursorPos(w/2 + 8, h/2)
- inputpw = read("*")
- if fs.exists("/user/"..inputuser.."/"..inputpw) == true then
- user = inputuser
- clear()
- printHeader()
- printCentered("Welcome back, "..user.."!", h/2)
- sleep(1.5)
- else
- clear()
- printHeader()
- printCentered("Wrong Username or Password!", h/2)
- sleep(2)
- end
- clear()
- printHeader()
- title = mm
- changeState("main")
- end
- local function printpw()
- if select == 1 then
- printCentered("[".."Create Account".."]", h/2 - 1)
- printBottom("**New Account on Desktop**")
- else printCentered("Create Account", h/2 - 1) end
- if select == 2 then
- printCentered("[".."Login Account".."]", h/2 + 1)
- printBottom("**Access Available Account**")
- else printCentered("Login Account", h/2 + 1) end
- if select == 3 then
- printCentered("[".."Back to Main Menu".."]", h/2 + 3)
- printBottom("**To Main Menu**")
- else printCentered("Back to Main Menu", h/2 + 3) end
- end
- local function inputpw()
- event, key = os.pullEvent("key")
- if key == 200 and select > 1 then
- select = select - 1
- elseif key == 208 and select < 3 then
- select = select + 1
- elseif key == 28 and select == 1 then
- title = "Account Registration"
- changeState("Register")
- elseif key == 28 and select == 2 then
- changeState("Login")
- elseif key == 28 and select == 3 then
- title = mm
- changeState("main")
- end
- end
- --[[Menu Tables]]--
- local state = {
- ["main"] = {
- printfunc = printMain,
- inputfunc = inputMain
- },
- ["Computer_List"] = {
- printfunc = printList,
- inputfunc = inputList
- },
- ["Command"] = {
- printfunc = printCommand,
- inputfunc = inputCommand
- },
- ["Simple_Math"] = {
- printfunc = printMath,
- inputfunc = inputMath
- },
- ["Games"] = {
- printfunc = printGames,
- inputfunc = inputGames
- },
- ["Programs"] = {
- printfunc = printprog,
- inputfunc = inputprog
- },
- ["Options"] = {
- printfunc = printOp,
- inputfunc = inputOp
- },
- ["Password"] = {
- printfunc = printpw,
- inputfunc = inputpw
- },
- ["Register"] = {
- printfunc = printpwR,
- inputfunc = inputpwR
- },
- ["Login"] = {
- printfunc = printpwL,
- inputfunc = inputpwL
- }
- }
- --[[For Changing Menus]]--
- local menustate = state["main"]
- function changeState(newstate)
- menustate = state[newstate]
- select = 1
- end
- local function Update()
- runningTime = os.time()
- printHeader()
- end
- --[[Overall compiled functions]]--
- local function Main()
- os.startTimer(0.1)
- local event = os.pullEvent()
- if event == "timer" then
- clear()
- Update()
- menustate.printfunc()
- menustate.inputfunc()
- else
- runningTime = os.time()
- end
- end
- --[[Looping the main function]]--
- while nF do
- if term.isColor() then
- term.setBackgroundColour(colours.blue)
- term.setTextColour(colours.white)
- end
- Main()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement