Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- ZoS was created by Zachary Knoblauch
- --]]
- -- API
- os.loadAPI("ZROOT/API/GUIAPI")
- -- Error Handling
- if not http then
- print("You must have HTTP enabled in the config")
- end
- if not term.isColor() then
- print("You must be using an Advanced Computer")
- end
- if not fs.exists("ZROOT/API/GUIAPI") then
- shell.run("pastebin get qz7KGw3R ZROOT/API/GUIAPI")
- os.reboot()
- end
- -- Variables
- -- os variables
- version = "0.1"
- -- api bars and logo image loading
- fileCheck = GUIAPI.createBar( "bar" )
- skipfileCheck = GUIAPI.createDialogueBox("ZoS", {"Would you like to", "skip file checking?"}, "yn")
- dtopWallpaper = paintutils.loadImage("ZROOT/ICONS/.dtopWallpaper")
- tetrisLogo = paintutils.loadImage("ZROOT/ICONS/.tetrisLogo")
- sketchLogo = paintutils.loadImage("ZROOT/ICONS/.sketchLogo")
- firewolfLogo = paintutils.loadImage("ZROOT/ICONS/.firewolfLogo")
- -- Cordinates and context menus
- slc = 0
- contextX = 0
- contextY = 0
- -- Color Variables
- White = 1
- Orange = 2
- Magenta = 4
- LightBlue = 8
- Yellow = 16
- Lime = 32
- Pink = 64
- Gray = 128
- Grey = 128
- LightGray = 256
- LightGrey = 256
- Cyan = 512
- Purple = 1024
- Blue = 2048
- Brown = 4096
- Green = 8192
- Red = 16384
- Black = 32768
- -- Tables
- -- Functions
- function main()
- skipfileCheckingYN()
- end
- function accountCreation()
- print("Please select a username")
- username = read()
- print("Please select a password")
- password = read("*")
- userFile = fs.open("ZROOT/USER/.list", "w")
- userFile.write(""..username)
- userFile.write("\n{login="..textutils.serialize(username)..", password="..textutils.serialize(password).."}")
- userFile.close()
- shell.run("mkdir ZROOT/USER/"..username)
- shell.run("rm firsttime")
- end
- function cl()
- term.clear()
- term.setCursorPos(1,1)
- end
- function fatalError()
- print("Please re-install ZoS, a fatal error has occurred.\nZoS will now shutdown to prevent any harm to your computer")
- end
- function missingFileorFolder()
- cl()
- fatalError()
- sleep(4)
- os.reboot()
- end
- function skipfileCheckingYN()
- cl()
- results = skipfileCheck:draw( 9, 11, 7, colors.gray, colors.lightBlue, colors.white )
- if results == true then
- bootUpFs()
- elseif results == false then
- term.setBackgroundColor(Black)
- bootUp()
- end
- end
- function dlContextMenu1()
- term.setTextColor(Orange)
- term.setBackgroundColor(Gray)
- term.setCursorPos(1, 2)
- print("=-=-=-=-=-=-")
- term.setCursorPos(1, 3)
- term.setTextColor(Red)
- print(" shutdown ")
- term.setTextColor(Orange)
- term.setCursorPos(1, 4)
- print("=-=-=-=-=-=-")
- term.setCursorPos(1, 5)
- print(" restart ")
- term.setCursorPos(1, 6)
- print("=-=-=-=-=-=-")
- term.setCursorPos(1, 7)
- print(" Quit2Shell ")
- term.setCursorPos(1, 8)
- print("=-=-=-=-=-=-")
- print(" =-=File=-= ")
- end
- function dlContextMenu2()
- term.setTextColor(Orange)
- term.setBackgroundColor(Gray)
- term.setCursorPos(contextX, contextY)
- print(" ")
- term.setCursorPos(contextX, contextY+1)
- print(" Ink ")
- term.setCursorPos(contextX, contextY+2)
- print(" Paint ")
- term.setCursorPos(contextX, contextY+3)
- print(" ")
- end
- function fileChecking()
- cl()
- term.setCursorPos(19, 9)
- print("Loading ZoS")
- sleep(1.5)
- cl()
- term.setCursorPos(1, 1)
- print(version)
- term.setCursorPos(1, 1)
- fileCheck:draw( 9,11,30,colors.white,colors.green,true,colors.black,colors.white )
- sleep(1)
- if not fs.exists("ZROOT") then
- missingFileorFolder()
- else
- fileCheck:update(20)
- sleep(1)
- if not fs.exists("ZROOT/API") then
- missingFileorFolder()
- else
- fileCheck:update(40)
- sleep(1)
- if not fs.exists("ZROOT/DOC") then
- missingFileorFolder()
- else
- fileCheck:update(60)
- sleep(1)
- if not fs.exists("ZROOT/PROGRAMS") then
- missingFileorFolder()
- else
- fileCheck:update(80)
- sleep(1)
- if not fs.exists("ZROOT/USER") then
- missingFileorFolder()
- else
- fileCheck:update(90)
- sleep(1)
- if not fs.exists("ZROOT/ICONS") then
- missingFileorFolder()
- else
- fileCheck:update(100)
- sleep(1)
- end
- end
- end
- end
- end
- end
- end
- function drawDesktop()
- term.clear()
- term.setBackgroundColor(Blue)
- term.setCursorPos(1, 1)
- term.clearLine()
- term.setCursorPos(1, 1)
- term.setTextColor(Black)
- print("[Start]")
- paintutils.drawImage(dtopWallpaper, 1, 2)
- paintutils.drawImage(tetrisLogo, 3, 3)
- paintutils.drawImage(sketchLogo, 3, 8)
- paintutils.drawImage(firewolfLogo, 11, 3)
- term.setCursorPos(3, 6)
- term.setBackgroundColor(Cyan)
- print("Tetris")
- term.setCursorPos(3, 12)
- print("Sketch")
- term.setCursorPos(11, 8)
- print("Firewolf")
- end
- function Desktop()
- drawDesktop()
- while true do
- local event, button, X, Y = os.pullEventRaw()
- if slc == 0 then
- if event == "mouse_click" then
- if X >=2 and X <=6 and Y>=4 and Y<=6 and button == 1 then
- shell.run("ZROOT/PROGRAMS/bbtetris")
- drawDesktop()
- elseif X >=2 and X <=6 and Y>=8 and Y<=11 and button ==1 then
- shell.run("ZROOT/PROGRAMS/Sketch")
- drawDesktop()
- elseif X >=11 and X <=14 and Y>=4 and Y<=6 and button ==1 then
- shell.run("ZROOT/PROGRAMS/Firewolf")
- drawDesktop()
- elseif X >=2 and X <=8 and Y==1 and button ==1 then
- dlContextMenu1()
- slc = 1
- elseif X >= 1 and Y >=2 and button == 2 then slc = 2
- if X >=38 then
- contextX = 38
- end
- if Y >=14 then
- contextY = 14
- end
- if X <= 38 then
- contextX = X
- end
- if Y <= 14 then
- contextY = Y
- end
- dlContextMenu2()
- else
- drawDesktop()
- end
- end
- elseif slc == 1 then
- if X >=1 and X <=11 and button == 1 and Y== 3 then slc = 0
- os.shutdown()
- elseif X>=1 and X<=11 and Y==5 and button ==1 then slc = 0
- os.reboot()
- elseif X>=1 and X<=11 and Y==7 and button == 1 then slc = 0
- term.setBackgroundColor(Black)
- cl()
- write("CraftOS 1.5")
- break
- elseif X>=1 and X<=11 and Y==9 and button == 1 then slc = 0
- shell.run("ZROOT/PROGRAMS/ice-browser")
- else
- slc = 0
- drawDesktop()
- end
- elseif slc == 2 then
- if X >= contextX and X <= contextX+13 and Y==contextY+1 and button == 1 then slc = 0
- shell.run("ZROOT/PROGRAMS/ink")
- drawDesktop()
- elseif X>= contextX and X <=contextX+13 and Y==contextY+2 and button == 1 then slc = 0
- cl()
- print("What would you like to paint?")
- object = read()
- shell.run("paint ZROOT/USER/"..object)
- drawDesktop()
- else slc = 0
- drawDesktop()
- end
- end
- end
- end
- function bootUpFs()
- shell.run("ZROOT/PROGRAMS/LoginGUI")
- Desktop()
- end
- function bootUp()
- fileChecking()
- shell.run("ZROOT/PROGRAMS/LoginGUI")
- Desktop()
- end
- if not fs.exists("firsttime") then
- main()
- elseif fs.exists("firsttime") then
- print("We are now running the account creation process")
- accountCreation()
- os.reboot()
- end
- -- Main
- main()
Advertisement
Add Comment
Please, Sign In to add comment