Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Lithium Operating System by LegoStax
- I do not own the following programs included in this package: LuaIDE - GravityScore, Firewolf - GravityScore, nPaintPro - NitrogenFingers, Mouse File Browser - BigSHinyToys. Each program belongs to its owner.
- If you are going to use any of the code in this file and/or package, please give credit to me and/or the correct owner at the top of your code.
- NOTE: DO NOT REDISTRIBUTE THIS PACKAGE AS A WHOLE. ALL NOTES AT THE TOP OF EVERY FILE IN THIS PACKAGE MUST BE KEPT WHERE THEY ARE.
- Thanks! Enjoy!
- ]]--
- local openbar = false
- local running = true
- os.loadAPI(".programs/lith")
- if fs.exists(".programs/config") then
- config = {}
- local file = fs.open(".programs/config", "r")
- config = textutils.unserialize(file.readAll())
- file.close()
- end
- -- self-explanatory-GUI-drawing-function
- local function drawClosedStartBar()
- openbar = false
- if config.taskside == "top" then
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.lightGray)
- term.setCursorPos(1,1)
- term.write(" [@] ")
- elseif config.taskside == "right" then
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.lightGray)
- for y = 1,19 do
- term.setCursorPos(51,y)
- term.write(" ")
- end
- term.setCursorPos(51,9)
- term.write("<")
- elseif config.taskside == "bottom" then
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.lightGray)
- term.setCursorPos(1,19)
- term.write(" ^ ")
- elseif config.taskside == "left" then
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.lightGray)
- for y = 1,19 do
- term.setCursorPos(1,y)
- term.write(" ")
- end
- term.setCursorPos(1,9)
- term.write(">")
- end
- end
- -- self-explanatory-GUI-drawing-function
- local function drawOpenStartBar()
- openbar = true
- if config.taskside == "top" then
- term.setBackgroundColor(colors.gray)
- term.setCursorPos(1,1)
- term.write(" Explorer ")
- term.setCursorPos(1,2)
- term.write(" Settings ")
- term.setCursorPos(1,3)
- term.write(" Shutdown ")
- term.setCursorPos(1,4)
- term.write(" Restart ")
- term.setCursorPos(1,5)
- term.write(" CraftOS ")
- elseif config.taskside == "left" then
- term.setBackgroundColor(colors.gray)
- term.setCursorPos(1,1)
- term.write(" Explorer ")
- term.setCursorPos(1,2)
- term.write(" Settings ")
- term.setCursorPos(1,3)
- term.write(" Shutdown ")
- term.setCursorPos(1,4)
- term.write(" Restart ")
- term.setCursorPos(1,5)
- term.write(" CraftOS ")
- term.setCursorPos(1,6)
- term.write(" ")
- term.setCursorPos(1,7)
- term.write(" ")
- term.setCursorPos(1,8)
- term.write(" ")
- term.setCursorPos(1,9)
- term.write(" ")
- term.setCursorPos(1,10)
- term.write(" ")
- term.setCursorPos(1,11)
- term.write(" ")
- term.setCursorPos(1,12)
- term.write(" ")
- term.setCursorPos(1,13)
- term.write(" ")
- term.setCursorPos(1,14)
- term.write(" ")
- term.setCursorPos(1,15)
- term.write(" ")
- term.setCursorPos(1,16)
- term.write(" ")
- term.setCursorPos(1,17)
- term.write(" ")
- term.setCursorPos(1,18)
- term.write(" ")
- term.setCursorPos(1,19)
- term.write(" ")
- elseif config.taskside == "bottom" then
- term.setBackgroundColor(colors.gray)
- term.setCursorPos(1,15)
- term.write(" Explorer ")
- term.setCursorPos(1,16)
- term.write(" Settings ")
- term.setCursorPos(1,17)
- term.write(" Shutdown ")
- term.setCursorPos(1,18)
- term.write(" Restart ")
- term.setCursorPos(1,19)
- term.write(" CraftOS ")
- elseif config.taskside == "right" then
- term.setBackgroundColor(colors.gray)
- term.setCursorPos(43,1)
- term.write(" Explorer ")
- term.setCursorPos(43,2)
- term.write(" Settings ")
- term.setCursorPos(43,3)
- term.write(" Shutdown ")
- term.setCursorPos(43,4)
- term.write(" Restart ")
- term.setCursorPos(43,5)
- term.write(" CraftOS ")
- term.setCursorPos(43,6)
- term.write(" ")
- term.setCursorPos(43,7)
- term.write(" ")
- term.setCursorPos(43,8)
- term.write(" ")
- term.setCursorPos(43,9)
- term.write(" ")
- term.setCursorPos(43,10)
- term.write(" ")
- term.setCursorPos(43,11)
- term.write(" ")
- term.setCursorPos(43,12)
- term.write(" ")
- term.setCursorPos(43,13)
- term.write(" ")
- term.setCursorPos(43,14)
- term.write(" ")
- term.setCursorPos(43,15)
- term.write(" ")
- term.setCursorPos(43,16)
- term.write(" ")
- term.setCursorPos(43,17)
- term.write(" ")
- term.setCursorPos(43,18)
- term.write(" ")
- term.setCursorPos(43,19)
- term.write(" ")
- end
- end
- -- self-explanatory-GUI-drawing-function
- local function drawDesktop()
- term.setBackgroundColor(config.bgcolor)
- for y = 1,19 do
- for x = 1,51 do
- term.setCursorPos(x,y)
- term.write(" ")
- end
- end
- bg = paintutils.loadImage(config.desktop_img)
- paintutils.drawImage(bg,1,1)
- end
- -- Time update function
- local function displayTime()
- term.setTextColor(colors.white)
- -- check for taskbar side
- if config.taskside == "top" then
- -- update time
- time = textutils.formatTime(os.time(), false)
- term.setCursorPos(44,1)
- term.write(time.." ")
- elseif config.taskside == "bottom" then
- time = textutils.formatTime(os.time(), false)
- term.setCursorPos(44,19)
- term.write(time.." ")
- elseif config.taskside == "left" then
- if openbar == true then
- time = textutils.formatTime(os.time(), false)
- term.setCursorPos(1,19)
- term.write(time.." ")
- end
- elseif config.taskside == "right" then
- if openbar == true then
- time = textutils.formatTime(os.time(), false)
- term.setCursorPos(44,19)
- term.write(time.." ")
- end
- end
- timeout = os.startTimer(0.8)
- end
- function drawRightClick(x,y)
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.red)
- term.setCursorPos(x,y)
- term.write(" Users ")
- term.setTextColor(colors.white)
- term.setCursorPos(x,y+1)
- term.write(" Run ")
- end
- function runProgram()
- term.setBackgroundColor(colors.gray)
- term.setCursorPos(18,7)
- term.write(" Run Program ")
- term.setBackgroundColor(colors.lime)
- term.setCursorPos(18,8)
- term.write(" ")
- term.setCursorPos(18,9)
- term.write(" ")
- term.setCursorPos(18,10)
- term.write(" ")
- term.setCursorPos(19,9)
- write ""
- program = read()
- shell.run(program)
- end
- function drawScreen()
- drawDesktop()
- drawClosedStartBar()
- displayTime()
- end
- -- draw the screen for the first time
- drawScreen()
- -- Event handler:
- while running do
- event, button, x, y = os.pullEvent()
- if event == "mouse_click" then
- if button == 1 then
- if config.taskside == "top" then
- if x >= 24 and x <= 26 and y == 1 then
- drawOpenStartBar()
- event, button, x, y = os.pullEvent("mouse_click")
- if button == 1 then
- if x >= 2 and x <= 8 and y == 1 then
- shell.run(".programs/explorer")
- drawScreen()
- elseif x >= 2 and x <= 8 and y == 2 then
- shell.run(".programs/settings")
- elseif x >= 2 and x <= 8 and y == 3 then
- os.shutdown()
- elseif x >= 2 and x <= 8 and y == 4 then
- os.reboot()
- elseif x >= 2 and x <= 8 and y == 5 then
- running = false
- else
- drawScreen()
- end
- end
- end
- elseif config.taskside == "left" then
- if x == 1 and y == 9 then
- drawOpenStartBar()
- choice = false
- while not choice do
- event, button, x, y = os.pullEvent()
- if event == "mouse_click" then
- if button == 1 then
- if x >= 2 and x <= 8 and y == 1 then
- shell.run(".programs/explorer")
- drawScreen()
- choice = true
- elseif x >= 2 and x <= 8 and y == 2 then
- shell.run(".programs/settings")
- choice = true
- elseif x >= 2 and x <= 8 and y == 3 then
- os.shutdown()
- elseif x >= 2 and x <= 8 and y == 4 then
- os.reboot()
- elseif x >= 2 and x <= 8 and y == 5 then
- running = false
- choice = true
- else
- drawScreen()
- choice = true
- end
- end
- elseif event == "timer" and button == timeout then
- displayTime()
- end
- end
- end
- elseif config.taskside == "bottom" then
- if x >= 24 and x <= 26 and y == 19 then
- drawOpenStartBar()
- event, button, x, y = os.pullEvent("mouse_click")
- if button == 1 then
- if x >= 2 and x <= 8 and y == 15 then
- shell.run(".programs/explorer")
- drawScreen()
- elseif x >= 2 and x <= 8 and y == 16 then
- shell.run(".programs/settings")
- elseif x >= 2 and x <= 8 and y == 17 then
- os.shutdown()
- elseif x >= 2 and x <= 8 and y == 18 then
- os.reboot()
- elseif x >= 2 and x <= 8 and y == 19 then
- running = false
- else
- drawScreen()
- end
- end
- end
- elseif config.taskside == "right" then
- if x == 51 and y == 9 then
- drawOpenStartBar()
- choice = false
- while not choice do
- event, button, x, y = os.pullEvent()
- if event == "mouse_click" then
- if button == 1 then
- if x >= 44 and x <= 51 and y == 1 then
- shell.run(".programs/explorer")
- drawScreen()
- choice = true
- elseif x >= 44 and x <= 51 and y == 2 then
- shell.run(".programs/settings")
- choice = true
- elseif x >= 44 and x <= 51 and y == 3 then
- os.shutdown()
- elseif x >= 44 and x <= 51 and y == 4 then
- os.reboot()
- elseif x >= 44 and x <= 51 and y == 5 then
- running = false
- choice = true
- else
- drawScreen()
- choice = true
- end
- end
- elseif event == "timer" and button == timeout then
- displayTime()
- end
- end
- end
- end
- elseif button == 2 then
- drawRightClick(x,y)
- choice = false
- while not choice do
- event, p1, p2, p3 = os.pullEvent()
- if event == "timer" and button == timeout then
- displayTime()
- elseif event == "mouse_click" then
- if p2 >= x and p2 <= x+7 and p3 == y then
- shell.run(".programs/users")
- choice = true
- elseif p2 >= x and p2 <= x+7 and p3 == y+1 then
- runProgram()
- drawScreen()
- choice = true
- else
- drawScreen()
- choice = true
- end
- end
- end
- drawScreen()
- end
- elseif event == "timer" and button == timeout then
- displayTime()
- elseif event == "key" then
- if button == keys.leftCtrl then
- runProgram()
- drawScreen()
- choice = true
- end
- end
- end
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- print("Thank you for using Lithium OS by LegoStax")
- shell.run("rom/programs/shell")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement