Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Table of contents-like thing
- 1. Start of goroutines stuff ~150
- ]]
- logo = paintutils.loadImage("library/logo.nfp")
- --print the beautiful logo
- term.setBackgroundColor(colors.white)
- term.clear(1,1)
- --get center
- w,h = term.getSize()
- w=w-9
- h=h-7
- w=w/2
- h=h/2
- term.setTextColor(colors.black)
- paintutils.drawImage(logo,w,h)
- --loads a single function to assist with actually printing loading
- function cPrint(x, text)
- local w,h = term.getSize()
- local pos = w - #text
- pos = pos/2
- term.setCursorPos(pos,x)
- print(text)
- end
- cPrint(14,"Loading")
- function clear(px, py)
- term.clear()
- term.setCursorPos(px, py)
- end
- --APIs
- if not redirect then
- os.loadAPI("library/redirect")
- end
- if not goroutine then
- os.loadAPI("library/goroutine")
- end
- --PAINTUTILS IMAGES
- noIconThing = paintutils.loadImage("library/border.nfp")
- login = paintutils.loadImage("library/login.nfp")
- --shell.run(program) replacement:
- --[[
- shell = {}
- function shell.run(program)
- os.run({}, program)
- end
- function shell.exit()
- error()
- end
- copied straight from shell VV
- function shell.resolve( _sPath )
- local sStartChar = string.sub( _sPath, 1, 1 )
- if sStartChar == "/" or sStartChar == "\\" then
- return fs.combine( "", _sPath )
- else
- return fs.combine( sDir, _sPath )
- end
- end
- function shell.resolveProgram( _sCommand )
- Substitute aliases firsts
- if tAliases[ _sCommand ] ~= nil then
- _sCommand = tAliases[ _sCommand ]
- end
- If the path is a global path, use it directly
- local sStartChar = string.sub( _sCommand, 1, 1 )
- if sStartChar == "/" or sStartChar == "\\" then
- local sPath = fs.combine( "", _sCommand )
- if fs.exists( sPath ) and not fs.isDir( sPath ) then
- return sPath
- end
- return nil
- end
- Otherwise, look on the path variable
- for sPath in string.gmatch(sPath, "[^:]+") do
- sPath = fs.combine( shell.resolve( sPath ), _sCommand )
- if fs.exists( sPath ) and not fs.isDir( sPath ) then
- return sPath
- end
- end
- Not found
- return nil
- end
- another one copied:
- function shell.resolve( _sPath )
- local sStartChar = string.sub( _sPath, 1, 1 )
- if sStartChar == "/" or sStartChar == "\\" then
- return fs.combine( "", _sPath )
- else
- return fs.combine( sDir, _sPath )
- end
- end]]
- ---------------------------------------------------------------------------
- --now we find startup programs. If none are
- --found, we'll create an empty table.
- if fs.exists("config/startups") then
- config = fs.open("config/startup", "w")
- startups = config.readLine()
- config.close()
- startups = textutils.unserialize(startups)
- else
- startups = {}
- end
- --now, we find the desktop color
- if fs.exists("config/desktopColor") then
- config = fs.open("config/desktopColor")
- desktopColor = config.readLine()
- config.close()
- else
- desktopColor = colors.green
- end
- --put a paintutil image at the center
- function centDrawImage(image,width,height)
- local w,h=term.getSize()
- local width=w-width
- local height=h-height
- width=width/2
- height=height/2
- paintutils.drawImage(image,width,height)
- end
- --find the admin account--- currently the only
- --one. If not found, create temp one just in
- --case the user has deleted it via CraftOS
- accountDetails = {}
- if fs.exists("config/adminAcc") then
- config = fs.open("config/adminAcc", "r")
- adminAcc = config.readLine()
- config.close()
- accountDetails = textutils.unserialize(adminAcc)
- else
- accountDetails["name"] = "Pass is 'hi'."
- --^^ clever right?
- accountDetails["pass"] = "hi"
- end
- --Default Callbacks
- function clickedCyborg() end
- function clickedMenuProgram() end
- function clickedApps() end
- function clickedFile() end
- function clickedEdit() end
- function clickedWindow() end
- --moar functions
- --syntax types: #,#,#,#,T/F,Table
- dropDownMenu(x,y,width,length,scrollbar,items)
- end
- -----------------------------------------------
- --GOROUTINE FUNCTIONS |
- -----------------------------------------------
- routines = {}
- --child functions
- --Cyborg's shell
- function findIt()
- end
- --menu bar
- function menuBar()
- term.setBackgroundColor(colors.white)
- term.setCursorPos(1,1)
- print(" C "..topProgram.." Apps File Edit Window ")
- paintutils.draw(5,5,colors.red)
- --^^that doesn't want to draw
- evt, p1, p2, p3 = os.pullEvent()
- if evt == "mouse_click" and p2 == 1 then
- if p1 == 2 then
- --we do our callback
- clickedCyborg()
- end
- term.setCursorPos(5,5)
- print("test")
- while true do
- sleep(0.1)
- end
- end
- --new shells
- function newShell()
- end
- --dock
- function findItDock()
- end
- --parrent function:
- function main()
- -- note that main reacts badly to print,
- --and generaly I/O from my experince.
- test = goroutine.spawn("menu",menuBar)
- while true do
- _, key = os.pullEvent("key")
- if key == keys.backspace then
- break
- end
- end
- end
- -----------------------------------------------
- --[[
- Now that we've loaded everything there is to
- load, we'll check if any keys are pressed and
- do stuff accordinly.
- ]]
- os.startTimer(1.5)
- evt, p1 = os.pullEvent()
- if evt == "key" or evt == "char" then
- if p1 == 46 or p1 == "c" then
- term.setBackgroundColor(colors.black)
- clear(1,1)
- noErrorShutdown = true
- --^^so shell runs just 1 time VV run shell
- os.run({}, "rom/programs/shell")
- end
- elseif evt == "timer" then
- end
- --
- --LOGIN SCREEN(finaly)
- local incorrect = true
- while incorrect do
- term.setBackgroundColor(colors.lightBlue)
- clear(1,1)
- paintutils.drawPixel(99,99,colors.lightGray)
- centDrawImage(login,25,11)
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.lightGray)
- cPrint(4,"Login")
- term.setBackgroundColor(colors.white)
- cPrint(9,"Admin Pass:")
- term.setCursorPos(20,10)
- term.setTextColor(colors.red)
- input = read("*")
- if input == accountDetails["pass"] then
- incorrect = false
- elseif input == "easterEgg" then
- textutils.slowPrint("Nice find on the easter egg. Rebooting...")
- os.reboot()
- end
- term.setBackgroundColor(colors.lightBlue)
- term.setTextColor(colors.black)
- clear(1,1)
- end
- --execute everything
- --temp:
- topProgram = "FindIt"
- goroutine.run(main,false)
Advertisement
Add Comment
Please, Sign In to add comment