Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Variable
- os.loadAPI("Ds_Data/kernal")
- os.loadAPI("Ds_Data/errorC")
- local w,h = term.getSize()
- local tArgs = {...}
- local config = "/DS_Data/.conf"
- local bg = string.sub(kernal.getLine(config, 7), string.find(kernal.getLine(config, 7), ":")+2)
- local bg_col = tonumber(string.sub(kernal.getLine(config, 7), string.find(kernal.getLine(config, 7), ":")+2))
- local osVer = string.sub(kernal.getLine(config, 6), string.find(kernal.getLine(config, 6), ":")+2)
- local brunning = true
- local slc = 0
- local _mtext = tonumber(string.sub(kernal.getLine(config, 9), string.find(kernal.getLine(config, 9), ":")+2))
- local _mback = tonumber(string.sub(kernal.getLine(config, 10), string.find(kernal.getLine(config, 10), ":")+2))
- local images = "Documents/Images/"
- --Tables
- local menu = {
- [1] = {txt = ""; tcol = _mtext; bcol = _mback; x = 1; xx = 7; y = 1; cmd = function() slc = 1 end};
- [2] = {txt = " "; tcol = _mtext; bcol = _mback; x = 1; xx = 12; y = 2; cmd = function() end};
- [3] = {txt = " Programs > "; tcol = _mtext; bcol = _mback; x = 1; xx = 12; y = 3; cmd = function() end};
- [4] = {txt = " Settings > "; tcol = _mtext; bcol = _mback; x = 1; xx = 12; y = 4; cmd = function() end};
- [5] = {txt = " Lua Prompt "; tcol = _mtext; bcol = _mback; x = 1; xx = 12; y = 5; cmd = function() term.setBackgroundColor(colors.black) term.setTextColor(1) shell.run("lua") end};
- [6] = {txt = " Quit "; tcol = _mtext; bcol = _mback; x = 1; xx = 12; y = 6; cmd = function() term.setBackgroundColor(colors.black) term.setCursorPos(1,1) term.clear() brunning = false end};
- [7] = {txt = " Shutdown "; tcol = _mtext; bcol = _mback; x = 1; xx = 12; y = 7; cmd = function() os.shutdown() end};
- [8] = {txt = " Logoff "; tcol = _mtext; bcol = _mback; x = 1; xx = 12; y = 8; cmd = function() end};
- [9] = {txt = " Reboot "; tcol = _mtext; bcol = _mback; x = 1; xx = 12; y = 9; cmd = function() os.reboot() end};
- [10] = {txt = " "; tcol = _mtext; bcol = _mback; x = 1; xx = 12; y = 10; cmd = function() error("Test Error") end};
- }
- --Functions
- local function tb_Draw()
- term.setCursorPos(1,1)
- term.setBackgroundColor(8)
- term.setTextColor(1)
- term.clearLine()
- print("[Begin]")
- term.setCursorPos(math.floor(w)-#osVer, 1)
- print(osVer)
- end
- local function clear(bcol)
- term.setBackgroundColor(bcol)
- term.clear()
- end
- local function drawMenu()
- for k,v in pairs(menu) do
- term.setBackgroundColor(v.bcol)
- term.setTextColor(v.tcol)
- term.setCursorPos(v.x, v.y)
- print(v.txt)
- end
- end
- local function drawScreen(bcol, bimage)
- clear(bcol)
- if bimage == "None" then bimage = images.."bg.npg" end
- paintutils.drawImage(paintutils.loadImage(images.."bg.npg"), 1, 1)
- tb_Draw()
- end
- local function menuClick()
- for k,v in pairs(menu) do
- if e[1] == "mouse_click" then
- if e[2] == 1 then
- if e[3] >= v.x and e[3] <= v.xx and e[4] == v.y then
- v.cmd()
- else slc = 0 drawScreen(bg_col, bg)
- end
- end
- end
- end
- end
- local function getFile(url, path)
- download = http.get(url)
- kernal.fwrite(path, download.readAll())
- end
- --Main code
- local function main()
- drawScreen(bg_col, bg)
- while brunning do
- e = {os.pullEvent()}
- if slc == 0 then
- drawScreen(bg_col, bg)
- if e[1] == "mouse_click" then
- if e[2] == 1 then
- if e[3] >= 1 and e[3] <= 7 and e[4] == 1 then
- slc = 1
- drawMenu()
- end
- end
- end
- elseif slc == 1 then
- drawMenu()
- menuClick()
- end
- end
- end
- errorC.A_crash(main, "center", colors.blue, 1)
Advertisement
Add Comment
Please, Sign In to add comment