Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.clear()
- term.setCursorPos(1,1)
- local version = "0.2"
- local programs = {"help", "redstone", "edit", "exit"}
- --Color Set Functions--
- function white()
- term.setTextColor(1)
- end
- function yellow()
- term.setTextColor(16)
- end
- function blue()
- term.setTextColor(2048)
- end
- function green()
- term.setTextColor(8192)
- end
- function red()
- term.setTextColor(16384)
- end
- function black()
- term.setTextColor(32768)
- end
- --Text Functions
- function drawLine()
- print("---------------------------------------------------")
- end
- function centerText(text)
- local x,y = term.getSize()
- local x2,y2 = term.getCursorPos()
- term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
- write(text)
- end
- function drawLogo(text)
- red()
- drawLine()
- white()
- centerText(text)
- red()
- drawLine()
- white()
- end
- function drawSubLogo(text)
- centerText(text)
- red()
- drawLine()
- white()
- end
- function drawTopLogo(text)
- red()
- drawLine()
- white()
- centerText(text)
- end
- function clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- function press()
- red()
- centerText("~")
- yellow()
- centerText("Press anything to continue!")
- white()
- os.pullEvent("key")
- sleep(0.1)
- end
- --Main Programs
- function drawMain()
- clear()
- drawLogo("StriteOS")
- drawSubLogo("~Version "..version.."!~")
- print()
- red()
- write("> ")
- white()
- local com = string.lower(read())
- if com == "redstone" or com == "rs" then
- redstone()
- elseif com == "exit" or com == "out" then
- exit()
- elseif com == "help" or com == "programs" then
- help()
- elseif com == "edit" then
- edit()
- else
- print()
- centerText("Unknown command, please try again!")
- print()
- press()
- drawMain()
- end
- end
- function rsC(side, colorName, colorNumber)
- term.setTextColor(colorNumber)
- local rsOnorOff = rs.testBundledInput(side, colorNumber)
- if rsOnorOff == true then
- centerText(colorName.." Cable Online!")
- elseif rsOnorOff == false then
- centerText(colorName.." Cable Offline!")
- white()
- end
- print()
- end
- function rsCI()
- white true do
- local event, param = os.pullEvent()
- if event == "key" then
- break
- else
- rsC("bottom", "White", 1)
- rsC("bottom", "Orange", 2)
- rsC("bottom", "Magenta", 4)
- rsC("bottom", "Light Blue", 8)
- rsC("bottom", "Yellow", 16)
- rsC("bottom", "Lime", 32)
- end
- end
- function redstone()
- local cablesNum = 6
- clear()
- drawLogo("StriteOS")
- drawSubLogo("Redstone Panel Tab!")
- print()
- centerText("-Available Cables-")
- print()
- rsCI()
- print()
- press()
- end
- function help()
- clear()
- drawLogo("StriteOS")
- drawSubLogo("Help Tab!")
- centerText("Programs available:")
- print()
- for i=1,#programs do
- centerText("-"..programs[i].."-")
- print()
- end
- press()
- drawMain()
- end
- function edit()
- clear()
- drawLogo("StriteOS")
- drawSubLogo("Editing Files Tab!")
- print()
- red()
- write("File's Name:> ")
- white()
- local fname = read()
- if fname == "exit" or fname == "Exit" or fname == "leave" or fname == "Leave" then
- print()
- centerText("Exiting...")
- press()
- drawMain()
- else
- if fs.exists(fname) then
- clear()
- drawLogo("StriteOS")
- drawSubLogo("Opening "..fname.."!")
- sleep(0.6)
- shell.run("edit "..fname)
- else
- print()
- centerText("Sorry, that file does not exist.")
- print()
- sleep(0.2)
- centerText("You should try the 'create' command!")
- print()
- sleep(0.2)
- centerText("Type 'exit' to get back to the Desktop!")
- print()
- press()
- sleep(0.2)
- edit()
- end
- end
- end
- function exit()
- clear()
- drawLogo("StriteOS")
- drawSubLogo("Are you sure you want to exit StriteOS? (y/n)")
- print()
- red()
- write("> ")
- white()
- local eyn = string.lower(read())
- if eyn == "y" or eyn == "yes" then
- term.clear()
- term.setCursorPos(1,1)
- drawLogo("StriteOS")
- drawSubLogo("Exiting StriteOS.")
- sleep(0.8)
- shell.run("reboot")
- elseif eyn == "n" or eyn == "no" then
- term.clear()
- term.setCursorPos(1,1)
- drawLogo("StriteOS")
- drawSubLogo("Returning to Desktop.")
- sleep(0.8)
- drawMain()
- end
- end
- --Main
- drawMain()
Advertisement
Add Comment
Please, Sign In to add comment