Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Minif OS
- --By Minif
- --Load Cores
- if fs.exists("/system/cores/file") then
- os.loadAPI("/system/cores/file")
- else
- mos.osBSOD("Critical core missing.","/system/cores/file is missing, and is needed to run.","Please re-install this file")
- end
- --Functions and Variables
- mos.osRunning = true
- mos.osUserBGImageExists = false
- mos.osUserAdmin = false
- function osLoadPrefs()
- local pref = fs.open("/system/user/"..mos.osEnteredUser.."/config", "r")
- local readFile = pref.readLine()
- if fs.exists(readFile) and not (fs.isDir(readFile)) then
- os_UserBGImage = paintutils.loadImage(readFile)
- mos.osUserBGImageExists = true
- end
- local readLine = pref.readLine()
- if readLine == "true" then
- mos.osUserAdmin = true
- end
- pref.close()
- end
- --Drawing
- function osDrawDesktop()
- mos.osFillBG(colors.cyan)
- if mos.osUserBGImageExists then
- paintutils.drawImage(os_UserBGImage,1,2)
- else
- if osBGImageExists then
- paintutils.drawImage(os_BGImage,1,1)
- end
- end
- end
- function osDrawMenu()
- paintutils.drawBox(1,1,mos.osScreenSizeX,1,colors.blue)
- term.setBackgroundColor(colors.lightBlue)
- term.setTextColor(colors.black)
- term.setCursorPos(1,1)
- term.write("M >")
- term.setCursorPos(5,1)
- term.write("File >")
- term.setCursorPos(12,1)
- term.write("System >")
- end
- function osDrawAll()
- term.setCursorBlink(false)
- osLoadPrefs()
- osDrawDesktop()
- osDrawMenu()
- end
- --Menu Routines
- function osMenuM()
- term.setBackgroundColor(colors.gray)
- term.setTextColor(colors.white)
- term.setCursorPos(1,1)
- term.write("M v")
- term.setCursorPos(1,2)
- term.write("Info ")
- term.setCursorPos(1,3)
- term.write("Log Out ")
- term.setCursorPos(1,4)
- term.write("Shut Down")
- osPEvent, osPB, osPX, osPY = os.pullEvent("mouse_click")
- if osPEvent == "mouse_click" then
- if osPB == 1 and osPY == 3 and osPX<=9 then
- mos.osRunning = false
- else if osPB == 1 and osPY == 4 and osPX<=9 then
- os.shutdown()
- else if osPB == 1 and osPY == 2 and osPX<=9 then
- if fs.exists("system/tools/about") then
- shell.run("system/tools/about")
- else
- mos.osBSOD("Critical file missing.","/system/tools/about is missing, and is needed to run.","Please re-install this file")
- end
- end
- end
- end
- end
- end
- function osMenuFile()
- term.setBackgroundColor(colors.gray)
- term.setTextColor(colors.white)
- term.setCursorPos(5,1)
- term.write("File v")
- term.setCursorPos(5,2)
- term.write("Write ")
- term.setCursorPos(5,3)
- term.write("Paint ")
- term.setCursorPos(5,4)
- term.write("Search")
- term.setCursorPos(5,5)
- term.write("build ")
- osPEvent, osPB, osPX, osPY = os.pullEvent("mouse_click")
- if osPB == 1 and osPY == 2 and osPX >= 5 and osPX <= 10 then
- if fs.exists("system/tools/medit") then
- shell.run("system/tools/medit")
- else
- mos.osBSOD("Critical file missing.","/system/tools/medit is missing, and is needed to run.","Please re-install this file")
- end
- else if osPB == 1 and osPY == 3 and osPX >= 5 and osPX <=10 then
- if fs.exists("system/tools/mpaint") then
- shell.run("system/tools/mpaint")
- else
- mos.osBSOD("Critical file missing.","/system/tools/mpaint is missing, and is needed to run.","Please re-install this file")
- end
- else if osPB == 1 and osPY == 5 and osPX >= 5 and osPX <= 10 then
- if fs.exists("run") then
- shell.run("run")
- end
- else if osPB == 1 and osPY == 4 and osPX >= 5 and osPX <= 10 then
- if fs.exists("system/tools/look") then
- shell.run("system/tools/look")
- else
- mos.osBSOD("Critical file missing.","/system/tools/look is missing, and is needed to run.","Please re-install this file")
- end
- end
- end
- end
- end
- end
- function osMenuSystem()
- term.setBackgroundColor(colors.gray)
- term.setTextColor(colors.white)
- term.setCursorPos(12,1)
- term.write("System v")
- term.setCursorPos(12,2)
- term.write("Shell ")
- term.setCursorPos(12,3)
- term.write("Settings ")
- term.setCursorPos(12,4)
- term.write("Run Program")
- osPEvent, osPB, osPX, osPY = os.pullEvent("mouse_click")
- if osPB == 1 and osPY == 2 and osPX >= 12 and osPX <= 22 then
- if mos.osUserAdmin then
- mos.osFillBG(colors.black)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- print("Enter 'exit' to return to MinifOS")
- shell.run("shell")
- return
- else
- mos.osDrawPerm("Shell")
- end
- else if osPB == 1 and osPY == 3 and osPX >= 12 and osPX <=22 then
- if fs.exists("system/tools/settings") then
- shell.run("system/tools/settings")
- return
- else
- mos.osBSOD("Critical file missing.","/system/tools/settings is missing, and is needed to run.","Please re-install this file")
- end
- else if osPB == 1 and osPY == 4 and osPX >= 12 and osPX <= 22 then
- if fs.exists("system/tools/run") then
- shell.run("system/tools/run")
- else
- mos.osBSOD("Critical file missing.","/system/tools/run is missing, and is needed to run.","Please re-install this file")
- end
- end
- end
- end
- end
- --Input Events
- local function handleClick(button,x,y)
- if button == 1 and y == 1 and x <= 3 then
- osMenuM()
- osDrawAll()
- end
- if button == 1 and y == 1 and x >= 5 and x <=10 then
- osMenuFile()
- osDrawAll()
- end
- if button == 1 and y == 1 and x >= 12 and x <=19 then
- osMenuSystem()
- osDrawAll()
- end
- end
- local function menuInput()
- osPEvent, osP1, osP2, osP3, osP4, osP5 = os.pullEvent()
- if osPEvent == "mouse_click" then
- handleClick(osP1,osP2,osP3)
- end
- end
- --Execution
- osLoadPrefs()
- osDrawAll()
- while mos.osRunning do
- menuInput()
- end
Advertisement
Add Comment
Please, Sign In to add comment