Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Last Edit 8:27am
- --Variables
- os.loadAPI("DS_Data/kernal")
- os.loadAPI("DS_Data/ccatch")
- local tArgs = {...}
- local config = "DS_Data/.conf"
- local images = "Documents/Images/"
- local w,h = term.getSize()
- local brunning = true
- local slc = 0
- local _osVer = string.sub(kernal.getLine(config, 1), string.find(kernal.getLine(config, 1), ":")+2)
- local _tbcol = string.sub(kernal.getLine(config, 2), string.find(kernal.getLine(config, 2), ":")+2)
- local _tbtext = string.sub(kernal.getLine(config, 3), string.find(kernal.getLine(config, 3), ":")+2)
- local _bgcolor = tonumber(string.sub(kernal.getLine(config, 4), string.find(kernal.getLine(config, 4), ":")+2))
- local _bgimage = string.sub(kernal.getLine(config, 5), string.find(kernal.getLine(config, 5), ":")+2)
- local _mtext = tonumber(string.sub(kernal.getLine(config, 6), string.find(kernal.getLine(config, 6), ":") +2))
- local _mback = tonumber(string.sub(kernal.getLine(config, 7), string.find(kernal.getLine(config, 7), ":") +2))
- local _allowBegin = string.sub(kernal.getLine(config, 8), string.find(kernal.getLine(config, 8), ":") +2)
- --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() shell.run("edit",config) 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() shell.run("lua") term.setBackgroundColor(colors.black) term.setTextColor(1) 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 = " Logoff "; tcol = _mtext; bcol = _mback; x = 1; xx = 12; y = 7; cmd = function() end};
- [8] = {txt = " Reboot "; tcol = _mtext; bcol = _mback; x = 1; xx = 12; y = 8; cmd = function() os.reboot() end};
- [9] = {txt = " Shutdown "; tcol = _mtext; bcol = _mback; x = 1; xx = 12; y = 9; cmd = function() os.shutdown() end};
- [10] = {txt = " "; tcol = _mtext; bcol = _mback; x = 1; xx = 12; y = 10; cmd = function() error("test error")end};
- }
- local security = {
- [1] = {txt = ""; tcol = _mtext; bcol = _mback; x = 9; xx = 18; y = 1; cmd = function() slc = 2 end};
- [2] = {txt = " "; tcol = _mtext; bcol = _mback; x = 9; xx = 21; y = 2; cmd = function() end};
- [3] = {txt = " Turrets On "; tcol = _mtext; bcol = _mback; x = 9; xx = 21; y = 3; cmd = function() redstone.setBundledOutput("back", colors.subtract(redstone.getBundledOutput("back"), colors.red)) end};
- [4] = {txt = " Turrets Off "; tcol = _mtext; bcol = _mback; x = 9; xx = 21; y = 4; cmd = function() redstone.setBundledOutput("back", colors.combine(redstone.getBundledOutput("back"), colors.red)) end};
- [5] = {txt = " Shields On "; tcol = _mtext; bcol = _mback; x = 9; xx = 21; y = 5; cmd = function() redstone.setBundledOutput("back", colors.subtract(redstone.getBundledOutput("back"), colors.green)) end};
- [6] = {txt = " Shields Off "; tcol = _mtext; bcol = _mback; x = 9; xx = 21; y = 6; cmd = function() redstone.setBundledOutput("back", colors.combine(redstone.getBundledOutput("back"), colors.green)) end};
- [7] = {txt = " "; tcol = _mtext; bcol = _mback; x = 9; xx = 21; y = 7; cmd = function() end};
- }
- --Functions
- local function clear(bcol)
- term.setBackgroundColor(bcol)
- term.clear()
- end
- local function tb_draw()
- term.setCursorPos(1,1)
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.black)
- term.clearLine()
- print("[Start] [Security]")
- term.setCursorPos(math.floor(w)-#_osVer, 1)
- print(_osVer)
- 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 drawSecurity()
- for k, v in pairs(security) do
- term.setBackgroundColor(v.bcol)
- term.setTextColor(v.tcol)
- term.setCursorPos(v.x, v.y)
- print(v.txt)
- end
- end
- local function drawStatus()
- local w,h = term.getSize()
- local text = " T S "
- term.setCursorPos(w-#text, h)
- term.setBackgroundColor(colors.white)
- write(text)
- if redstone.testBundledInput("back", colors.red) then
- paintutils.drawImage(paintutils.loadImage(images.."off.npg"), 46, 19)
- else
- paintutils.drawImage(paintutils.loadImage(images.."on.npg"), 46, 19)
- end
- if redstone.testBundledInput("back", colors.green) then
- paintutils.drawImage(paintutils.loadImage(images.."off.npg"), 49, 19)
- else
- paintutils.drawImage(paintutils.loadImage(images.."on.npg"), 49, 19)
- 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()
- drawStatus()
- end
- local function menuClick(button, x, y)
- testClick(button, x, y)
- for k,v in pairs(menu) do
- if button == 1 then
- if x >= v.x and x <= v.xx and y == 1 then
- v.cmd()
- slc = 0
- drawScreen(_bgcolor, _bgimage)
- end
- elseif button == 2 then
- slc = 0
- drawScreen(_bgcolor, _bgimage)
- end
- end return true
- end
- local function securityClick(button, x, y)
- testClick(button, x, y)
- for k,v in pairs(security) do
- if button == 1 then
- if x >= v.x and x <= v.xx and y == 1 then
- v.cmd()
- slc = 0
- drawScreen(_bgcolor, _bgimage)
- end
- elseif button == 2 then
- slc = 0
- drawScreen(_bgcolor, _bgimage)
- end
- end return true
- end
- local function getFile(url, path)
- dowload = http.get(url)
- kernal.fwrite(path, dowload.readAll())
- end
- local function testClick(button, x, y)
- term.setBackgroundColor(colors.yellow)
- term.setCursorPos(1,5)
- print(button, " X:",x, ", Y:", y)
- end
- --Main
- local function main()
- drawScreen(_bgcolor, _bgimage)
- while brunning do
- local event, button, x, y = os.pullEvent("mouse_click")
- if slc == 0 then
- drawScreen(_bgcolor, _bgimage)
- if button == 1 then
- if x >= 1 and x <= 7 and y == 1 then
- slc = 1
- drawMenu()
- testClick(button, x, y)
- elseif x >= 9 and x <= 18 and y == 1 then
- slc = 2
- drawSecurity()
- testClick(button, x, y)
- end
- end
- elseif slc == 1 then
- drawMenu()
- menuClick(button, x, y)
- elseif slc == 2 then
- drawSecurity()
- securityClick(button, x, y)
- end
- end
- end
- ccatch.A_crash(main, "center", 1, 8)
Add Comment
Please, Sign In to add comment