Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Last Edit 7:48pm
- --Variables
- os.loadAPI("DS_Data/kernal")
- os.loadAPI("DS_Data/ccatch")
- tArgs = {...}
- config = "DS_Data/.conf"
- images = "Documents/Images/"
- w,h = term.getSize()
- brunning = true
- slc = "0"
- subSlc = 0
- _osVer = string.sub(kernal.getLine(config, 1), string.find(kernal.getLine(config, 1), ":")+2)
- _tbcol = string.sub(kernal.getLine(config, 2), string.find(kernal.getLine(config, 2), ":")+2)
- _tbtext = string.sub(kernal.getLine(config, 3), string.find(kernal.getLine(config, 3), ":")+2)
- _bgcolor = tonumber(string.sub(kernal.getLine(config, 4), string.find(kernal.getLine(config, 4), ":")+2))
- _bgimage = string.sub(kernal.getLine(config, 5), string.find(kernal.getLine(config, 5), ":")+2)
- _mtext = tonumber(string.sub(kernal.getLine(config, 6), string.find(kernal.getLine(config, 6), ":") +2))
- _mback = tonumber(string.sub(kernal.getLine(config, 7), string.find(kernal.getLine(config, 7), ":") +2))
- _allowBegin = string.sub(kernal.getLine(config, 8), string.find(kernal.getLine(config, 8), ":") +2)
- reactor = "BigReactors-Reactor_0"
- --Tables
- mainMenu = {
- [1] = {txt = ""; tcol = _mtext; bcol = _mback; x = 1; xx = 7; y = 1; cmd = function() slc = "0" 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() shell.run("edit",config) 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() brunning = false term.setBackgroundColor(colors.black) term.setCursorPos(1,1) term.clear() 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};
- }
- securityMenu = {
- [1] = {txt = ""; tcol = _mtext; bcol = _mback; x = 9; xx = 18; y = 1; cmd = function() slc = "0" 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() term.setCursorPos(1,5) term.setTextColor(colors.lightGray) term.setBackgroundColor(colors.gray) print("Turrets On") 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() term.setCursorPos(1,5) term.setTextColor(colors.lightGray) term.setBackgroundColor(colors.gray) print("Turrets Off") 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() term.setCursorPos(1,5) term.setTextColor(colors.lightGray) term.setBackgroundColor(colors.gray) print("Shields On") 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() term.setCursorPos(1,5) term.setTextColor(colors.lightGray) term.setBackgroundColor(colors.gray) print("Shields Off") 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};
- }
- powerMenu = {
- [1] = {txt = ""; tcol = _mtext; bcol = _mback; x = 20; xx = 27; y = 1; cmd = function() slc = "0" end};
- [2] = {txt = " "; tcol = _mtext; bcol = _mback; x = 20; xx = 31; y = 2; cmd = function() end};
- [3] = {txt = " Reactor > "; tcol = _mtext; bcol = _mback; x = 20; xx = 31; y = 3; cmd = function() slc = "3.1" end};
- [4] = {txt = " Turbines > "; tcol = _mtext; bcol = _mback; x = 20; xx = 31; y = 4; cmd = function() slc = "3.2" end};
- [5] = {txt = " "; tcol = _mtext; bcol = _mback; x = 20; xx = 31; y = 5; cmd = function() end};
- }
- reactorMenu = {
- [1] = {txt = " On "; tcol = _mtext; bcol = _mback; x = 32; xx = 36; y = 3; cmd = function() peripheral.wrap(reactor).setActive(true) end};
- [2] = {txt = " Off "; tcol = _mtext; bcol = _mback; x = 32; xx = 36; y = 4; cmd = function() peripheral.wrap(reactor).setActive(false) end};
- }
- turbinesMenu = {
- [1] = {txt = " Turbine 1 > "; tcol = _mtext; bcol = _mback; x = 32; xx = 44; y = 4; cmd = function() slc = "3.2.1" end};
- [2] = {txt = " Turbine 2 > "; tcol = _mtext; bcol = _mback; x = 32; xx = 44; y = 5; cmd = function() slc = "3.2.2" end};
- [3] = {txt = " Turbine 3 > "; tcol = _mtext; bcol = _mback; x = 32; xx = 44; y = 6; cmd = function() slc = "3.2.3" end};
- [4] = {txt = " Turbine 4 > "; tcol = _mtext; bcol = _mback; x = 32; xx = 44; y = 7; cmd = function() slc = "3.2.4" end};
- }
- turbineMenu = {
- [1] = {txt = " Activate "; tcol = _mtext; bcol = _mback; x = 45; xx = 52; y = 3 + subSlc; cmd = function() peripheral.wrap("BigReactors-Turbine_"..subSlc).setActive(true) end};
- [2] = {txt = " Deactivate "; tcol = _mtext; bcol = _mback; x = 45; xx = 52; y = 4 + subSlc; cmd = function() peripheral.wrap("BigReactors-Turbine_"..subSlc).setActive(false) end};
- [3] = {txt = " Engage Coils "; tcol = _mtext; bcol = _mback; x = 45; xx = 52; y = 5 + subSlc; cmd = function() peripheral.wrap("BigReactors-Turbine_"..subSlc).setInductorEngaged(true) end};
- [4] = {txt = " Disengage Coils "; tcol = _mtext; bcol = _mback; x = 45; xx = 52; y = 6 + subSlc; cmd = function() peripheral.wrap("BigReactors-Turbine_"..subSlc).setInductorEngaged(false) end};
- }
- --Functions
- function clear(bcol)
- term.setBackgroundColor(bcol)
- term.clear()
- end
- function draw_line(mon, x, y, length, color)
- mon.setBackgroundColor(color)
- mon.setCursorPos(x,y)
- mon.write(string.rep(" ", length))
- end
- 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
- function tb_draw()
- term.setCursorPos(1,1)
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.black)
- term.clearLine()
- print("[Start] [Security] [Power]")
- term.setCursorPos(math.floor(w)-#_osVer, 1)
- print(_osVer)
- --sleep(0.1)
- drawStatus()
- end
- function drawMenu(menuVar)
- for k,v in pairs(menuVar) do
- term.setBackgroundColor(v.bcol)
- term.setTextColor(v.tcol)
- term.setCursorPos(v.x, v.y)
- print(v.txt)
- end
- end
- 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
- function menuClick(menuVar, button, x, y)
- for k,v in pairs(menuVar) do
- if button == 1 then
- if x >= v.x and x <= v.xx and y == v.y then
- v.cmd()
- drawScreen(_bgcolor, _bgimage)
- end
- elseif button == 2 then
- slc = "0"
- drawScreen(_bgcolor, _bgimage)
- end
- end return true
- end
- function getFile(url, path)
- dowload = http.get(url)
- kernal.fwrite(path, dowload.readAll())
- end
- function drawTurbine(turbine, monitor, id)
- local w,h = monitor.getSize()
- local y = 1 + (id * 6)
- local x = 25
- monitor.setTextScale(0.5)
- for z = 0, 5 do
- draw_line(monitor, 1, y+z, x+2, colors.lightGray)
- if z > 0 and z < 5 then
- draw_line(monitor, 2, y+z, x, colors.gray)
- end
- end
- --Rotor speed
- speed = math.floor(turbine.getRotorSpeed())
- rswidth = math.floor((100*(speed/2000))/4)
- draw_line(monitor, 2, y+1, rswidth, colors.lime)
- --Steam level
- steam = math.floor(turbine.getInputAmount())
- slwidth = math.floor((100*(steam/4000))/4)
- draw_line(monitor, 2, y+2, slwidth, colors.white)
- --Water level
- water = math.floor(turbine.getOutputAmount())
- wlwidth = math.floor((100*(water/4000))/4)
- draw_line(monitor, 2, y+3, wlwidth, colors.blue)
- --Rf storage
- power = math.floor(turbine.getEnergyStored())
- pwidth = math.floor((100*(power/1000000))/4)
- draw_line(monitor, 2, y+4, pwidth, colors.red)
- --Text
- monitor.setBackgroundColor(colors.black)
- monitor.setTextColor(colors.yellow)
- monitor.setCursorPos(30, y)
- monitor.write("Turbine "..id..": "..turbine.getEnergyProducedLastTick().." RF/T")
- monitor.setCursorPos(30, y+1)
- monitor.write("Rotor Speed: "..speed)
- monitor.setCursorPos(30, y+2)
- monitor.write("Steam Level: "..steam)
- monitor.setCursorPos(30, y+3)
- monitor.write("Water Level: "..water)
- monitor.setCursorPos(30, y+4)
- monitor.write("Power Stored: "..power.." RF")
- end
- function drawTurbines()
- monitor = peripheral.wrap("monitor_0")
- monitor.setBackgroundColor(colors.black)
- monitor.clear()
- monitor.setTextScale(0.5)
- for i = 0, 3 do
- turbine = peripheral.wrap("BigReactors-Turbine_"..i)
- drawTurbine(turbine, monitor, i)
- end
- end
- --Main
- function drawMonitors()
- while true do
- drawScreen(_bgcolor, _bgimage)
- drawTurbines()
- sleep(0.5)
- end
- end
- function terminalClick()
- local event, button, x, y = os.pullEvent("mouse_click")
- drawScreen(_bgcolor, _bgimage)
- if slc == "0" then
- drawScreen(_bgcolor, _bgimage)
- if button == 1 then
- if x >= 1 and x <= 7 and y == 1 then
- slc = "1"
- drawMenu(mainMenu)
- elseif x >= 9 and x <= 18 and y == 1 then
- slc = "2"
- drawMenu(securityMenu)
- elseif x >= 20 and x <= 26 and y == 1 then
- slc = "3"
- drawMenu(powerMenu)
- end
- end
- elseif slc == "1" then
- drawMenu(mainMenu)
- menuClick(mainMenu, button, x, y)
- elseif slc == "2" then
- drawMenu(securityMenu)
- menuClick(securityMenu, button, x, y)
- elseif slc == "3" then
- drawMenu(powerMenu)
- menuClick(powerMenu, button, x, y)
- elseif slc == "3.1" then
- drawMenu(powerMenu)
- drawMenu(reactorMenu)
- menuClick(reactorMenu, button, x, y)
- elseif slc == "3.2" then
- drawMenu(powerMenu)
- drawMenu(turbinesMenu)
- menuClick(turbinesMenu, button, x, y)
- elseif string.find(slc, "3.2.")then
- subSlc = tonumber(string.sub(slc, 5))
- print(subSlc)
- drawMenu(powerMenu)
- drawMenu(turbinesMenu)
- drawMenu(turbineMenu)
- menuClick(turbineMenu)
- end
- start()
- end
- function start()
- clear()
- parallel.waitForAny(drawMonitors, terminalClick)
- end
- ccatch.A_crash(start, "center", 1, 8)
Add Comment
Please, Sign In to add comment