diff --git a/monitor-system/.vscode/settings.json b/.vscode/settings.json similarity index 100% rename from monitor-system/.vscode/settings.json rename to .vscode/settings.json diff --git a/Config/colors.lua b/Config/colors.lua new file mode 100644 index 0000000..ef92263 --- /dev/null +++ b/Config/colors.lua @@ -0,0 +1,37 @@ +local colors = { + red = 0xFF0000, + lime = 0x00FF00, + blue = 0x0000FF, + magenta = 0xFF00FF, + yellow = 0xFFFF00, + cyan = 0x00FFFF, + green = 0x008000, + purple = 0x800080, + brown = 0xA52A2A, + steelBlue = 0x4682B4, + chocolate = 0xD2691E, + lightGray = 0xD3D3D3, + darkGray = 0xA9A9A9, + rosyBrown = 0xBC8F8F, + white = 0xFFFFFF, + black = 0x000000, + darkSlateGrey = 0x2F4F4F, + machineBackground = colors.darkGray, + progressBackground = colors.lightGray, + labelColor = colors.chocolate, + errorColor = colors.red, + idleColor = colors.purple, + workingColor = colors.steelBlue, + positiveEUColor = colors.lime, + negativeEUColor = colors.brown, + timeColor = colors.purple, + textColor = colors.black, + hudColor = colors.darkSlateGrey, + mainColor = colors.rosyBrown, + background = colors.black, + accentA = colors.cyan, + accentB = colors.magenta, + barColor = colors.blue +} + +return colors diff --git a/monitor-system/src/data/database/cleanroom.lua b/Config/database/cleanroom.lua similarity index 93% rename from monitor-system/src/data/database/cleanroom.lua rename to Config/database/cleanroom.lua index 9f04de8..801b407 100644 --- a/monitor-system/src/data/database/cleanroom.lua +++ b/Config/database/cleanroom.lua @@ -1,4 +1,4 @@ -local adresses = { +local addresses = { laserEngraver1 = "d9a13648-977b-464e-a228-46bf12e38525", laserEngraver2 = "a4fd6874-f4a9-40d9-a47b-f88c3ef7d0fa", laserEngraver3 = "843022a0-5687-49d9-b94c-6637ae8a8ec9", @@ -10,4 +10,4 @@ local adresses = { cleanroom = "753f5619-7076-45c0-8f0a-f3899bae00e1" } -return adresses +return addresses diff --git a/monitor-system/src/data/database/energy-buffer.lua b/Config/database/energy-buffer.lua similarity index 100% rename from monitor-system/src/data/database/energy-buffer.lua rename to Config/database/energy-buffer.lua diff --git a/monitor-system/src/data/database/multi-blocks.lua b/Config/database/multi-blocks.lua similarity index 100% rename from monitor-system/src/data/database/multi-blocks.lua rename to Config/database/multi-blocks.lua diff --git a/Libraries/ARGraphics.lua b/Libraries/Graphics/ARGraphics.lua similarity index 100% rename from Libraries/ARGraphics.lua rename to Libraries/Graphics/ARGraphics.lua diff --git a/Libraries/ARWidgets.lua b/Libraries/Graphics/ARWidgets.lua similarity index 81% rename from Libraries/ARWidgets.lua rename to Libraries/Graphics/ARWidgets.lua index 3ece547..53f45aa 100644 --- a/Libraries/ARWidgets.lua +++ b/Libraries/Graphics/ARWidgets.lua @@ -5,7 +5,7 @@ event = require("event") thread = require("thread") get = require("easy") ARG = require("ARGraphics") -config = require("config") +colors = require("colors") local ARWidgets = {} local firstRead, lastRead, counter, currentIO = 0, 0, 1, 1 @@ -36,20 +36,20 @@ function ARWidgets.powerDisplay(glasses, data, x, y, w, h) maxEU = math.floor(string.gsub(data.getSensorInformation()[3], "([^0-9]+)", "") + 0) percentage = currentEU / maxEU if initializePowerDisplay then - ARG.hudRectangle(glasses, x, y, w, h, hudColor) - ARG.hudRectangle(glasses, x, y + h, w, 12, hudColor, 0.6) - ARG.hudTriangle(glasses, {x + 2, y + 3}, {x + 2, y + 3 + h - 6}, {x + 2 + h - 6, y + 3 + h - 6}, hudColor) + ARG.hudRectangle(glasses, x, y, w, h, colors.hudColor) + ARG.hudRectangle(glasses, x, y + h, w, 12, colors.hudColor, 0.6) + ARG.hudTriangle(glasses, {x + 2, y + 3}, {x + 2, y + 3 + h - 6}, {x + 2 + h - 6, y + 3 + h - 6}, colors.hudColor) ARG.hudTriangle( glasses, {x + 2 + w - 4, y + 3}, {x + 2 + w - 4 - (h - 6), y + 3}, {x + 2 + w - 4, y + 3 + h - 6}, - hudColor + colors.hudColor ) - ARG.hudRectangle(glasses, x, y + h, 25, 12, hudColor) - ARG.hudTriangle(glasses, {x + 25, y + h}, {x + 25, y + h + 12}, {x + 37, y + h + 12}, hudColor) - ARG.hudRectangle(glasses, x + w - 25, y + h, 25, 12, hudColor) - ARG.hudTriangle(glasses, {x + w - 37, y + h}, {x + w - 25, y + h + 12}, {x + w - 25, y + h}, hudColor) + ARG.hudRectangle(glasses, x, y + h, 25, 12, colors.hudColor) + ARG.hudTriangle(glasses, {x + 25, y + h}, {x + 25, y + h + 12}, {x + 37, y + h + 12}, colors.hudColor) + ARG.hudRectangle(glasses, x + w - 25, y + h, 25, 12, colors.hudColor) + ARG.hudTriangle(glasses, {x + w - 37, y + h}, {x + w - 25, y + h + 12}, {x + w - 25, y + h}, colors.hudColor) powerFill = ARG.hudQuad( glasses, @@ -57,7 +57,7 @@ function ARWidgets.powerDisplay(glasses, data, x, y, w, h) {x + 2 + h - 6, y + 3 + h - 6}, {math.min(x + 2 + w - 5, (w - 4) * percentage), y + 3 + (h - 6)}, {math.min(x + 2 + w - 5 - (h - 6), (w - 4) * percentage - (h - 6)), y + 3}, - workingColor + colors.workingColor ) powerEmpty = ARG.hudQuad( @@ -66,14 +66,14 @@ function ARWidgets.powerDisplay(glasses, data, x, y, w, h) {math.min(x + 2 + w - 5, (w - 4) * percentage), y + 3 + (h - 6)}, {x + 2 + w - 5, y + 3 + h - 6}, {x + 2 + w - 5 - (h - 6), y + 3}, - machineBackground + colors.machineBackground ) - maxEnergyObj = ARG.hudText(glasses, "", x + w - 88, y - 8, idleColor) - currentEnergyObj = ARG.hudText(glasses, "", x + 2, y - 8, workingColor) + maxEnergyObj = ARG.hudText(glasses, "", x + w - 88, y - 8, colors.idleColor) + currentEnergyObj = ARG.hudText(glasses, "", x + 2, y - 8, colors.workingColor) currentFillrateObj = ARG.hudText(glasses, "", x + w / 2 - 20, y + h + 1, 0xFFFFFF) - percentageObj = ARG.hudText(glasses, "", x + w / 2 - 5, y - 8, labelColor) - timeObj = ARG.hudText(glasses, "", x + 35, y + h + 1, labelColor) + percentageObj = ARG.hudText(glasses, "", x + w / 2 - 5, y - 8, colors.labelColor) + timeObj = ARG.hudText(glasses, "", x + 35, y + h + 1, colors.labelColor) initializePowerDisplay = false end if currentIO >= 0 then @@ -114,53 +114,53 @@ function ARWidgets.powerDisplay(glasses, data, x, y, w, h) end function ARWidgets.minimapOverlay(glasses) --Minimap Borders - ARG.hudRectangle(glasses, 728, 10, 123, 3, hudColor) - ARG.hudRectangle(glasses, 728, 130, 123, 3, hudColor) - ARG.hudRectangle(glasses, 728, 10, 3, 123, hudColor) - ARG.hudRectangle(glasses, 848, 10, 3, 123, hudColor) + ARG.hudRectangle(glasses, 728, 10, 123, 3, colors.hudColor) + ARG.hudRectangle(glasses, 728, 130, 123, 3, colors.hudColor) + ARG.hudRectangle(glasses, 728, 10, 3, 123, colors.hudColor) + ARG.hudRectangle(glasses, 848, 10, 3, 123, colors.hudColor) --Coordinate Borders - ARG.hudTriangle(glasses, {743, 133}, {728, 133}, {743, 143}, hudColor) - ARG.hudRectangle(glasses, 743, 133, 8, 10, hudColor) - ARG.hudRectangle(glasses, 751, 140, 170, 3, hudColor) + ARG.hudTriangle(glasses, {743, 133}, {728, 133}, {743, 143}, colors.hudColor) + ARG.hudRectangle(glasses, 743, 133, 8, 10, colors.hudColor) + ARG.hudRectangle(glasses, 751, 140, 170, 3, colors.hudColor) --Biome Borders - ARG.hudTriangle(glasses, {768, 143}, {753, 143}, {768, 153}, hudColor) - ARG.hudRectangle(glasses, 768, 150, 170, 3, hudColor) + ARG.hudTriangle(glasses, {768, 143}, {753, 143}, {768, 153}, colors.hudColor) + ARG.hudRectangle(glasses, 768, 150, 170, 3, colors.hudColor) ARG.hudRectangle(glasses, 829, 133, 50, 7, 0, 0.8) ARG.hudRectangle(glasses, 811, 143, 50, 7, 0, 0.8) --FPS Borders - ARG.hudRectangle(glasses, 728, 0, 150, 2, hudColor) - ARG.hudRectangle(glasses, 728, 0, 22, 12, hudColor) + ARG.hudRectangle(glasses, 728, 0, 150, 2, colors.hudColor) + ARG.hudRectangle(glasses, 728, 0, 22, 12, colors.hudColor) ARG.hudRectangle(glasses, 750, 2, 28, 8, 0, 0.8) - ARG.hudTriangle(glasses, {758, 2}, {750, 2}, {750, 10}, hudColor) + ARG.hudTriangle(glasses, {758, 2}, {750, 2}, {750, 10}, colors.hudColor) ARG.hudRectangle(glasses, 801, 2, 70, 8, 0, 0.8) ARG.hudRectangle(glasses, 851, 10, 5, 123, 0, 0.8) end function ARWidgets.hudOverlayBase(glasses, x, y) - local hotbarSplitter = ARG.hudRectangle(glasses, x, y, 183, 2, hudColor) - local expSplitter = ARG.hudRectangle(glasses, x, y - 6, 183, 2, hudColor) - local expOverlay = ARG.hudRectangle(glasses, x, y - 4, 183, 4, workingColor, 0.5) - local leftBorder = ARG.hudRectangle(glasses, x - 1, y - 13, 3, 38, hudColor) - local rightBorder = ARG.hudRectangle(glasses, x + 182, y - 5, 3, 30, hudColor) - local armorBox = ARG.hudRectangle(glasses, x, y - 27, 90, 15, hudColor, 0.0) - local hpBox = ARG.hudRectangle(glasses, x + 1, y - 15, 94, 10, hudColor, 0.7) + local hotbarSplitter = ARG.hudRectangle(glasses, x, y, 183, 2, colors.hudColor) + local expSplitter = ARG.hudRectangle(glasses, x, y - 6, 183, 2, colors.hudColor) + local expOverlay = ARG.hudRectangle(glasses, x, y - 4, 183, 4, colors.workingColor, 0.5) + local leftBorder = ARG.hudRectangle(glasses, x - 1, y - 13, 3, 38, colors.hudColor) + local rightBorder = ARG.hudRectangle(glasses, x + 182, y - 5, 3, 30, colors.hudColor) + local armorBox = ARG.hudRectangle(glasses, x, y - 27, 90, 15, colors.hudColor, 0.0) + local hpBox = ARG.hudRectangle(glasses, x + 1, y - 15, 94, 10, colors.hudColor, 0.7) local hpStopper = - ARG.hudQuad(glasses, {x + 88, y - 16}, {x + 77, y - 5}, {x + 108, y - 5}, {x + 97, y - 16}, hudColor) - local topBorder = ARG.hudRectangle(glasses, x + 4, y - 18, 178, 3, hudColor) - local topWedge = ARG.hudTriangle(glasses, {x + 4, y - 18}, {x - 1, y - 13}, {x + 4, y - 13}, hudColor) - local connector = ARG.hudTriangle(glasses, {x + 182, y - 18}, {x + 182, y}, {x + 200, y}, hudColor) - local topStrip = ARG.hudRectangle(glasses, x + 4, y - 17, 178, 1, workingColor) - local expWedge1 = ARG.hudTriangle(glasses, {x + 179, y - 4}, {x + 183, y}, {x + 183, y - 4}, hudColor) - local expWedge2 = ARG.hudTriangle(glasses, {x + 2, y - 5}, {x + 2, y}, {x + 6, y}, hudColor) + ARG.hudQuad(glasses, {x + 88, y - 16}, {x + 77, y - 5}, {x + 108, y - 5}, {x + 97, y - 16}, colors.hudColor) + local topBorder = ARG.hudRectangle(glasses, x + 4, y - 18, 178, 3, colors.hudColor) + local topWedge = ARG.hudTriangle(glasses, {x + 4, y - 18}, {x - 1, y - 13}, {x + 4, y - 13}, colors.hudColor) + local connector = ARG.hudTriangle(glasses, {x + 182, y - 18}, {x + 182, y}, {x + 200, y}, colors.hudColor) + local topStrip = ARG.hudRectangle(glasses, x + 4, y - 17, 178, 1, colors.workingColor) + local expWedge1 = ARG.hudTriangle(glasses, {x + 179, y - 4}, {x + 183, y}, {x + 183, y - 4}, colors.hudColor) + local expWedge2 = ARG.hudTriangle(glasses, {x + 2, y - 5}, {x + 2, y}, {x + 6, y}, colors.hudColor) --CPU Monitor - local base = ARG.hudRectangle(glasses, x + 185, y, 28, 24, hudColor) - local cpuStrip = ARG.hudRectangle(glasses, x + 185, y, 500, 3, hudColor) - local itemBorder1 = ARG.hudRectangle(glasses, x + 28 + 185, y + 3, 1, 21, workingColor, 0.8) - local itemBorder2 = ARG.hudRectangle(glasses, x + 28 + 185, y + 3, 61, 1, workingColor, 0.8) - local itemBorder3 = ARG.hudRectangle(glasses, x + 88 + 185, y + 3, 1, 21, workingColor, 0.8) - local itemBorder4 = ARG.hudRectangle(glasses, x + 28 + 185, y + 23, 61, 1, workingColor, 0.8) - local cpuBase1 = ARG.hudRectangle(glasses, x + 89 + 185, y, 5, 24, hudColor) + local base = ARG.hudRectangle(glasses, x + 185, y, 28, 24, colors.hudColor) + local cpuStrip = ARG.hudRectangle(glasses, x + 185, y, 500, 3, colors.hudColor) + local itemBorder1 = ARG.hudRectangle(glasses, x + 28 + 185, y + 3, 1, 21, colors.workingColor, 0.8) + local itemBorder2 = ARG.hudRectangle(glasses, x + 28 + 185, y + 3, 61, 1, colors.workingColor, 0.8) + local itemBorder3 = ARG.hudRectangle(glasses, x + 88 + 185, y + 3, 1, 21, colors.workingColor, 0.8) + local itemBorder4 = ARG.hudRectangle(glasses, x + 28 + 185, y + 23, 61, 1, colors.workingColor, 0.8) + local cpuBase1 = ARG.hudRectangle(glasses, x + 89 + 185, y, 5, 24, colors.hudColor) local connectorStrip = - ARG.hudQuad(glasses, {x + 182, y - 17}, {x + 182, y - 16}, {x + 213, y + 15}, {x + 213, y + 14}, workingColor) + ARG.hudQuad(glasses, {x + 182, y - 17}, {x + 182, y - 16}, {x + 213, y + 15}, {x + 213, y + 14}, colors.workingColor) end function popupText(glasses, text, x, y, color) local substringLength = 1 @@ -169,8 +169,8 @@ function popupText(glasses, text, x, y, color) local stepLength = substringLength * 5 local i = 1 local background = - ARG.hudQuad(glasses, {x - 5, y}, {x - 5, y + 9}, {x - 5 + 1, y + 9}, {x - 5 + 1, y}, machineBackground, 0.5) - local top = ARG.hudQuad(glasses, {x - 5, y - 1}, {x - 5, y}, {x - 5 + 1, y}, {x - 5 + 1, y - 1}, machineBackground) + ARG.hudQuad(glasses, {x - 5, y}, {x - 5, y + 9}, {x - 5 + 1, y + 9}, {x - 5 + 1, y}, colors.machineBackground, 0.5) + local top = ARG.hudQuad(glasses, {x - 5, y - 1}, {x - 5, y}, {x - 5 + 1, y}, {x - 5 + 1, y - 1}, colors.machineBackground) local bottom = ARG.hudQuad( glasses, @@ -178,7 +178,7 @@ function popupText(glasses, text, x, y, color) {x - 5, y + 10}, {x - 5 + 1, y + 10}, {x - 5 + 1, y + 9}, - machineBackground + colors.machineBackground ) local hudText = ARG.hudText(glasses, "", x + 1, y + 1, color) local wedge = @@ -188,7 +188,7 @@ function popupText(glasses, text, x, y, color) {x - 5, y - 1}, {x - 5, y + 10}, {x - 5 + 11, y + 10}, - machineBackground + colors.machineBackground ) local direction = 1 local function advance() @@ -236,7 +236,7 @@ function ARWidgets.fluidMonitor(glasses, x, y, fluidMap) {x - 8, y + 8 + i * h}, {x + w, y + 8 + i * h}, {x + w, y + i * h}, - hudColor, + colors.hudColor, 0.5 ) local top = @@ -246,7 +246,7 @@ function ARWidgets.fluidMonitor(glasses, x, y, fluidMap) {x - 10, y + i * h}, {x + w, y + i * h}, {x + w, y - 1 + i * h}, - hudColor + colors.hudColor ) local bottom = ARG.hudQuad( @@ -255,7 +255,7 @@ function ARWidgets.fluidMonitor(glasses, x, y, fluidMap) {x - 8, y + 9 + i * h}, {x + w, y + 9 + i * h}, {x + w, y + 8 + i * h}, - hudColor + colors.hudColor ) local fill = ARG.hudQuad( @@ -278,7 +278,7 @@ function ARWidgets.fluidMonitor(glasses, x, y, fluidMap) {x - 10, y + 9 + i * h}, {x - 6, y + 9 + i * h}, {x + 3, y + i * h}, - hudColor + colors.hudColor ) else local wedge = @@ -288,7 +288,7 @@ function ARWidgets.fluidMonitor(glasses, x, y, fluidMap) {x - 10, y + 9 + i * h}, {x + 3, y + 9 + i * h}, {x - 6, y + i * h}, - hudColor + colors.hudColor ) end entries = i @@ -301,7 +301,7 @@ function ARWidgets.fluidMonitor(glasses, x, y, fluidMap) {x - 2, y + 8 + entries * h}, {x + w, y + 8 + entries * h}, {x + w, y + entries * h}, - hudColor + colors.hudColor ) local verticalStrip = ARG.hudQuad( @@ -310,7 +310,7 @@ function ARWidgets.fluidMonitor(glasses, x, y, fluidMap) {x - 8, y - 2 + entries * h}, {x - 7, y - 2 + entries * h}, {x - 7, y}, - workingColor + colors.workingColor ) local diagonalStrip = ARG.hudQuad( @@ -319,7 +319,7 @@ function ARWidgets.fluidMonitor(glasses, x, y, fluidMap) {x, y + 6 + entries * h}, {x, y + 5 + entries * h}, {x - 7, y - 2 + entries * h}, - workingColor + colors.workingColor ) local horizontalStrip = ARG.hudQuad( @@ -328,7 +328,7 @@ function ARWidgets.fluidMonitor(glasses, x, y, fluidMap) {x, y + 6 + entries * h}, {x + w, y + 6 + entries * h}, {x + w, y + 5 + entries * h}, - workingColor + colors.workingColor ) initFluidMap = false elseif computer.uptime() - lastRefresh > 30 then @@ -364,11 +364,11 @@ local rollingTextObjects = {} local function rollingText(glasses, text, start, stop, y, color) local textObject = ARG.hudText(glasses, "", start, y, color) textObject.setAlpha(0.8) - local backgroundEndWedge = ARG.hudTriangle(glasses, {stop, y - 2}, {stop, y + 10}, {stop + 12, y + 10}, hudColor) + local backgroundEndWedge = ARG.hudTriangle(glasses, {stop, y - 2}, {stop, y + 10}, {stop + 12, y + 10}, colors.hudColor) local backgroundStartWedge = - ARG.hudTriangle(glasses, {start - 12, y - 2}, {start, y + 10}, {start + 12, y - 2}, hudColor) + ARG.hudTriangle(glasses, {start - 12, y - 2}, {start, y + 10}, {start + 12, y - 2}, colors.hudColor) local startWedge = - ARG.hudQuad(glasses, {start, y - 2}, {start, y + 8}, {start + 30, y + 8}, {start + 30, y - 2}, hudColor) + ARG.hudQuad(glasses, {start, y - 2}, {start, y + 8}, {start + 30, y + 8}, {start + 30, y - 2}, colors.hudColor) rollingTextObjects[#rollingTextObjects + 1] = { t = textObject, bew = backgroundEndWedge, @@ -459,27 +459,27 @@ function ARWidgets.itemTicker(glasses, x, y, w) end if initializeTicker then local background = - ARG.hudQuad(glasses, {x, y + 2}, {x, y + 14}, {x + w, y + 14}, {x + w, y + 2}, machineBackground, 0.5) - local top = ARG.hudQuad(glasses, {x, y}, {x, y + 2}, {x + w, y + 2}, {x + w, y}, hudColor) - local bottom = ARG.hudQuad(glasses, {x, y + 14}, {x, y + 20}, {x + w, y + 20}, {x + w, y + 14}, hudColor) + ARG.hudQuad(glasses, {x, y + 2}, {x, y + 14}, {x + w, y + 14}, {x + w, y + 2}, colors.machineBackground, 0.5) + local top = ARG.hudQuad(glasses, {x, y}, {x, y + 2}, {x + w, y + 2}, {x + w, y}, colors.hudColor) + local bottom = ARG.hudQuad(glasses, {x, y + 14}, {x, y + 20}, {x + w, y + 20}, {x + w, y + 14}, colors.hudColor) local bottomStripe = - ARG.hudQuad(glasses, {x, y + 17}, {x, y + 18}, {x + w, y + 18}, {x + w, y + 17}, workingColor) - local wedge = ARG.hudTriangle(glasses, {x - 20, y}, {x, y + 20}, {x, y}, hudColor) - local backgroundEndWedge = ARG.hudTriangle(glasses, {x, y + 2}, {x, y + 14}, {x + 12, y + 14}, hudColor) + ARG.hudQuad(glasses, {x, y + 17}, {x, y + 18}, {x + w, y + 18}, {x + w, y + 17}, colors.workingColor) + local wedge = ARG.hudTriangle(glasses, {x - 20, y}, {x, y + 20}, {x, y}, colors.hudColor) + local backgroundEndWedge = ARG.hudTriangle(glasses, {x, y + 2}, {x, y + 14}, {x + 12, y + 14}, colors.hudColor) local backgroundStartWedge = - ARG.hudTriangle(glasses, {x + w - 12, y + 2}, {x + w, y + 14}, {x + w + 12, y + 2}, hudColor) + ARG.hudTriangle(glasses, {x + w - 12, y + 2}, {x + w, y + 14}, {x + w + 12, y + 2}, colors.hudColor) local diagonalStripe = - ARG.hudQuad(glasses, {x - 16, y + 2}, {x, y + 18}, {x, y + 17}, {x - 15, y + 2}, workingColor) - local bottomBorder = ARG.hudRectangle(glasses, x + w - 170, y + 28, 170, 4, hudColor) - local dataBorder = ARG.hudRectangle(glasses, x + w - 170, 20, 170, 12, hudColor, 0.5) + ARG.hudQuad(glasses, {x - 16, y + 2}, {x, y + 18}, {x, y + 17}, {x - 15, y + 2}, colors.workingColor) + local bottomBorder = ARG.hudRectangle(glasses, x + w - 170, y + 28, 170, 4, colors.hudColor) + local dataBorder = ARG.hudRectangle(glasses, x + w - 170, 20, 170, 12, colors.hudColor, 0.5) local endWedge = - ARG.hudTriangle(glasses, {x + w - 182, y + 20}, {x + w - 170, y + 32}, {x + w - 170, y + 20}, hudColor) - local divisor1 = ARG.hudRectangle(glasses, x + w - 118, y + 20, 2, 12, hudColor) - local divisor2 = ARG.hudRectangle(glasses, x + w - 64, y + 20, 2, 12, hudColor) - local bottomDataStripe = ARG.hudRectangle(glasses, x + w - 168, y + 30, 168, 1, workingColor) - uniqueItems = ARG.hudText(glasses, "", x, y, workingColor, 0.75) - totalItems = ARG.hudText(glasses, "", x, y, workingColor, 0.75) - patterns = ARG.hudText(glasses, "", x, y, workingColor, 0.75) + ARG.hudTriangle(glasses, {x + w - 182, y + 20}, {x + w - 170, y + 32}, {x + w - 170, y + 20}, colors.hudColor) + local divisor1 = ARG.hudRectangle(glasses, x + w - 118, y + 20, 2, 12, colors.hudColor) + local divisor2 = ARG.hudRectangle(glasses, x + w - 64, y + 20, 2, 12, colors.hudColor) + local bottomDataStripe = ARG.hudRectangle(glasses, x + w - 168, y + 30, 168, 1, colors.workingColor) + uniqueItems = ARG.hudText(glasses, "", x, y, colors.workingColor, 0.75) + totalItems = ARG.hudText(glasses, "", x, y, colors.workingColor, 0.75) + patterns = ARG.hudText(glasses, "", x, y, colors.workingColor, 0.75) uniqueItems.setPosition((x + w - 114) * 1.33333, (y + 22) * 1.33333) totalItems.setPosition((x + w - 168) * 1.33333, (y + 22) * 1.33333) patterns.setPosition((x + w - 60) * 1.33333, (y + 22) * 1.33333) @@ -489,9 +489,9 @@ function ARWidgets.itemTicker(glasses, x, y, w) rollingText(glasses, name, x + w, x, y + 4, 0xAAAAAA) local function showChange() if amount > 0 then - rollingText(glasses, "+" .. amount, x + w, x, y + 4, positiveEUColor) + rollingText(glasses, "+" .. amount, x + w, x, y + 4, colors.positiveEUColor) else - rollingText(glasses, "" .. amount, x + w, x, y + 4, negativeEUColor) + rollingText(glasses, "" .. amount, x + w, x, y + 4, colors.negativeEUColor) end end event.timer(#name * 0.12, showChange, 1) @@ -517,20 +517,20 @@ function ARWidgets.itemTicker(glasses, x, y, w) end end function ARWidgets.crossHair(glasses, x, y) - local horizontal = ARG.hudRectangle(glasses, x, y + 5, 4, 1, workingColor, 0.5) - local vertical = ARG.hudRectangle(glasses, x + 5, y, 1, 4, workingColor, 0.5) - local horizontal2 = ARG.hudRectangle(glasses, x + 7, y + 5, 4, 1, workingColor, 0.5) - local vertical2 = ARG.hudRectangle(glasses, x + 5, y + 7, 1, 4, workingColor, 0.5) - local middle = ARG.hudRectangle(glasses, x + 4, y + 4, 3, 3, hudColor, 0.0) - local center = ARG.hudRectangle(glasses, x + 5, y + 5, 1, 1, hudColor, 0.7) + local horizontal = ARG.hudRectangle(glasses, x, y + 5, 4, 1, colors.workingColor, 0.5) + local vertical = ARG.hudRectangle(glasses, x + 5, y, 1, 4, colors.workingColor, 0.5) + local horizontal2 = ARG.hudRectangle(glasses, x + 7, y + 5, 4, 1, colors.workingColor, 0.5) + local vertical2 = ARG.hudRectangle(glasses, x + 5, y + 7, 1, 4, colors.workingColor, 0.5) + local middle = ARG.hudRectangle(glasses, x + 4, y + 4, 3, 3, colors.hudColor, 0.0) + local center = ARG.hudRectangle(glasses, x + 5, y + 5, 1, 1, colors.hudColor, 0.7) end local initializeCpuMonitor = true local cpuLights = {} function ARWidgets.cpuMonitor(glasses, x, y) if initializeCpuMonitor then - local cpuBase2 = ARG.hudRectangle(glasses, x + 94, y + 12, 8, 12, hudColor) - local cpuSplitter = ARG.hudRectangle(glasses, x + 89, y + 9, 400, 3, hudColor) - local cpuSplitter2 = ARG.hudRectangle(glasses, x + 102, y + 18, 380, 6, hudColor) + local cpuBase2 = ARG.hudRectangle(glasses, x + 94, y + 12, 8, 12, colors.hudColor) + local cpuSplitter = ARG.hudRectangle(glasses, x + 89, y + 9, 400, 3, colors.hudColor) + local cpuSplitter2 = ARG.hudRectangle(glasses, x + 102, y + 18, 380, 6, colors.hudColor) local function createCpuIndicator(cpuX, cpuY) local status = ARG.hudQuad( @@ -539,11 +539,11 @@ function ARWidgets.cpuMonitor(glasses, x, y) {cpuX + 6, cpuY + 6}, {cpuX + 16, cpuY + 6}, {cpuX + 10, cpuY}, - hudColor, + colors.hudColor, 1.0 ) local leftTriangle = - ARG.hudTriangle(glasses, {cpuX, cpuY}, {cpuX, cpuY + 6}, {cpuX + 6, cpuY + 6}, hudColor) + ARG.hudTriangle(glasses, {cpuX, cpuY}, {cpuX, cpuY + 6}, {cpuX + 6, cpuY + 6}, colors.hudColor) local rightTriangle = ARG.hudQuad( glasses, @@ -551,7 +551,7 @@ function ARWidgets.cpuMonitor(glasses, x, y) {cpuX + 16, cpuY + 6}, {cpuX + 18, cpuY + 6}, {cpuX + 18, cpuY}, - hudColor + colors.hudColor ) return status end @@ -568,9 +568,9 @@ function ARWidgets.cpuMonitor(glasses, x, y) end cpuNumber = cpuNumber + 1 end - local rowStop1 = ARG.hudRectangle(glasses, x + 94 + i * 17, y + 3, 300, 6, hudColor) - local rowStop2 = ARG.hudRectangle(glasses, x + 102 + j * 17, y + 12, 300, 6, hudColor) - local horizontalStrip = ARG.hudRectangle(glasses, x + 100, y + 22, 210, 1, workingColor) + local rowStop1 = ARG.hudRectangle(glasses, x + 94 + i * 17, y + 3, 300, 6, colors.hudColor) + local rowStop2 = ARG.hudRectangle(glasses, x + 102 + j * 17, y + 12, 300, 6, colors.hudColor) + local horizontalStrip = ARG.hudRectangle(glasses, x + 100, y + 22, 210, 1, colors.workingColor) local diagonalStrip = ARG.hudQuad( glasses, @@ -578,17 +578,17 @@ function ARWidgets.cpuMonitor(glasses, x, y) {x + 89, y + 12}, {x + 100, y + 23}, {x + 100, y + 22}, - workingColor + colors.workingColor ) initializeCpuMonitor = false end local cpus = comp.me_interface.getCpus() for i = 1, #cpus, 1 do if cpus[i].busy then - cpuLights[i].setColor(ARG.hexToRGB(positiveEUColor)) + cpuLights[i].setColor(ARG.hexToRGB(colors.positiveEUColor)) else cpuLights[i].setAlpha(0.7) - cpuLights[i].setColor(ARG.hexToRGB(workingColor)) + cpuLights[i].setColor(ARG.hexToRGB(colors.workingColor)) end end end @@ -598,30 +598,30 @@ function ARWidgets.displayTPS(glasses, x, y) if initializeTPS then initializeTPS = false local background = - ARG.hudQuad(glasses, {x + 40, y + 4}, {x + 40, y + 15}, {x + 93, y + 15}, {x + 105, y + 4}, hudColor, 0.6) - local startBlock = ARG.hudRectangle(glasses, x, y, 40, 23, hudColor) - local top = ARG.hudRectangle(glasses, x + 40, y, 65, 4, hudColor) - local bottom = ARG.hudRectangle(glasses, x + 40, y + 14, 50, 5, hudColor) + ARG.hudQuad(glasses, {x + 40, y + 4}, {x + 40, y + 15}, {x + 93, y + 15}, {x + 105, y + 4}, colors.hudColor, 0.6) + local startBlock = ARG.hudRectangle(glasses, x, y, 40, 23, colors.hudColor) + local top = ARG.hudRectangle(glasses, x + 40, y, 65, 4, colors.hudColor) + local bottom = ARG.hudRectangle(glasses, x + 40, y + 14, 50, 5, colors.hudColor) local wedge1 = - ARG.hudQuad(glasses, {x + 40, y + 19}, {x + 40, y + 23}, {x + 42, y + 23}, {x + 46, y + 19}, hudColor) - local wedge2 = ARG.hudQuad(glasses, {x + 105, y}, {x + 86, y + 19}, {x + 93, y + 19}, {x + 112, y}, hudColor) - local stripe1 = ARG.hudRectangle(glasses, x + 2, y + 20, 39, 1, workingColor) - local stripe2 = ARG.hudRectangle(glasses, x + 45, y + 16, 48, 1, workingColor) + ARG.hudQuad(glasses, {x + 40, y + 19}, {x + 40, y + 23}, {x + 42, y + 23}, {x + 46, y + 19}, colors.hudColor) + local wedge2 = ARG.hudQuad(glasses, {x + 105, y}, {x + 86, y + 19}, {x + 93, y + 19}, {x + 112, y}, colors.hudColor) + local stripe1 = ARG.hudRectangle(glasses, x + 2, y + 20, 39, 1, colors.workingColor) + local stripe2 = ARG.hudRectangle(glasses, x + 45, y + 16, 48, 1, colors.workingColor) local stripe3 = - ARG.hudQuad(glasses, {x + 41, y + 20}, {x + 41, y + 21}, {x + 45, y + 17}, {x + 45, y + 16}, workingColor) - local stripe4 = ARG.hudRectangle(glasses, x + 1, y + 2, 1, 19, workingColor) - TPSText = ARG.hudText(glasses, "", x + 42, y + 6, workingColor, 1) + ARG.hudQuad(glasses, {x + 41, y + 20}, {x + 41, y + 21}, {x + 45, y + 17}, {x + 45, y + 16}, colors.workingColor) + local stripe4 = ARG.hudRectangle(glasses, x + 1, y + 2, 1, 19, colors.workingColor) + TPSText = ARG.hudText(glasses, "", x + 42, y + 6, colors.workingColor, 1) end local tps = math.min(20.00, get.tps()) if tps > 15 then TPSText.setText("TPS: " .. string.sub(tps, 1, 5)) - TPSText.setColor(ARG.hexToRGB(positiveEUColor)) + TPSText.setColor(ARG.hexToRGB(colors.positiveEUColor)) elseif tps >= 10 then TPSText.setText("TPS: " .. string.sub(tps, 1, 5)) - TPSText.setColor(ARG.hexToRGB(workingColor)) + TPSText.setColor(ARG.hexToRGB(colors.workingColor)) else TPSText.setText("TPS: " .. string.sub(tps, 1, 4)) - TPSText.setColor(ARG.hexToRGB(negativeEUColor)) + TPSText.setColor(ARG.hexToRGB(colors.negativeEUColor)) end end function ARWidgets.clear() diff --git a/Libraries/graphics.lua b/Libraries/Graphics/graphics.lua similarity index 94% rename from Libraries/graphics.lua rename to Libraries/Graphics/graphics.lua index e8ba42e..52b1d8f 100644 --- a/Libraries/graphics.lua +++ b/Libraries/Graphics/graphics.lua @@ -1,16 +1,5 @@ comp = require("component") -color = { - red = 0xFF0000, - green = 0x00FF00, - blue = 0x0000FF, - purple = 0x5500FF, - cyan = 0x00A6FF, - lightGreen = 0x00CC00, - lightGray = 0x272c2e, - darkGray = 0x121010, - white = 0x000000, - black = 0x000000 -} +colors = require("colors") local graphics = {} function pixel(GPU, x, y, color) diff --git a/Libraries/gui.lua b/Libraries/Graphics/gui.lua similarity index 93% rename from Libraries/gui.lua rename to Libraries/Graphics/gui.lua index b8f92bf..ad57c11 100644 --- a/Libraries/gui.lua +++ b/Libraries/Graphics/gui.lua @@ -4,6 +4,7 @@ local thread = require("thread") local uc = require("unicode") local comp = require("component") GPU = comp.proxy(comp.get("f26678f4")) +local colors = require("colors") local gui, quit, editing = {}, false, false local currentWindows = {} @@ -36,9 +37,9 @@ function contextMenu(GPU, x, y, data) end local contextWindow = createWindow(GPU, longestData, #data * 2, "ContextMenu" .. contextMenus) GPU.setActiveBuffer(contextWindow) - draw.rect(GPU, 1, 1, longestData, #data * 2, color.lightGray) + draw.rect(GPU, 1, 1, longestData, #data * 2, colors.lightGray) for i = 1, #data do - draw.text(GPU, 1, 1 + i * 2 - 2, color.cyan, data[i]) + draw.text(GPU, 1, 1 + i * 2 - 2, colors.cyan, data[i]) end currentWindows["ContextMenu" .. contextMenus].x = x currentWindows["ContextMenu" .. contextMenus].y = y @@ -71,13 +72,13 @@ function processCommand(GPU, window, option) end GPU.setActiveBuffer(currentWindows["ColorBox"].page) if option == 1 then - draw.rect(GPU, 1, 1, 10, 10, color.red) + draw.rect(GPU, 1, 1, 10, 10, colors.red) end if option == 2 then - draw.rect(GPU, 1, 1, 10, 10, color.blue) + draw.rect(GPU, 1, 1, 10, 10, colors.blue) end if option == 3 then - draw.rect(GPU, 1, 1, 10, 10, color.green) + draw.rect(GPU, 1, 1, 10, 10, colors.green) end GPU.setActiveBuffer(0) end @@ -86,7 +87,7 @@ local i, xOffset, yOffset = 1, 0, 0 function mouseListener() function processClick(event, address, x, y, key, player) activeWindow = checkCollision(x, y) - draw.text(GPU, 1, 1, color.cyan, "Active window: " .. activeWindow) + draw.text(GPU, 1, 1, colors.cyan, "Active window: " .. activeWindow) if key == 1.0 and editing then if inContextMenu then contextMenus = 0 diff --git a/Libraries/widgets.lua b/Libraries/Graphics/widgets.lua similarity index 53% rename from Libraries/widgets.lua rename to Libraries/Graphics/widgets.lua index ff2058f..cc70c0e 100644 --- a/Libraries/widgets.lua +++ b/Libraries/Graphics/widgets.lua @@ -4,20 +4,15 @@ computer = require("computer") event = require("event") draw = require("graphics") util = require("utility") - -local mainColor = color.purple -local background = color.black -local accentA = color.cyan -local accentB = color.red -local barColor = color.blue +colors = require("colors") local widgets = {} function widgets.gtMachineInit(GPU, name, address) local maintenanceIndex = 0 local machine = util.machine(address) - draw.rect(GPU, 1, 1, 28, 9, background) - draw.text(GPU, 4, 3, mainColor, name) + draw.rect(GPU, 1, 1, 28, 9, colors.background) + draw.text(GPU, 4, 3, colors.mainColor, name) if machine ~= nil then for i = 1, #machine.getSensorInformation() do --Get maintenance index if string.match(machine.getSensorInformation()[i], "Problems") ~= nil then @@ -29,26 +24,26 @@ function widgets.gtMachineInit(GPU, name, address) if string.match(machine.getSensorInformation()[6], "tier") ~= nil then local tier = util.tier((string.gsub(machine.getSensorInformation()[6], "([^0-9]+)", "") - 1) / 10) if tier ~= nil then - draw.text(GPU, 4, 5, accentB, "" .. tier) + draw.text(GPU, 4, 5, colors.accentB, "" .. tier) end end --Check for parallel on Processing Arrays if string.match(machine.getSensorInformation()[7], "Parallel") ~= nil then local parallel = string.gsub(machine.getSensorInformation()[7], "([^0-9]+)", "") if parallel ~= nil then - draw.text(GPU, 11 + -(#parallel) .. "", 5, mainColor, parallel .. "x") + draw.text(GPU, 11 + -(#parallel) .. "", 5, colors.mainColor, parallel .. "x") end end end else - draw.text(GPU, 4, 5, errorColor, "Unknown") + draw.text(GPU, 4, 5, colors.errorColor, "Unknown") end - draw.rect(GPU, 3, 2, 3, 1, barColor) - draw.rect(GPU, 2, 2, 1, 7, barColor) - draw.rect(GPU, 3, 8, 20, 1, barColor) - draw.rect(GPU, 24, 8, 3, 1, barColor) - draw.rect(GPU, 27, 2, 1, 7, barColor) - draw.rect(GPU, 7, 2, 21, 1, barColor) + draw.rect(GPU, 3, 2, 3, 1, colors.barColor) + draw.rect(GPU, 2, 2, 1, 7, colors.barColor) + draw.rect(GPU, 3, 8, 20, 1, colors.barColor) + draw.rect(GPU, 24, 8, 3, 1, colors.barColor) + draw.rect(GPU, 27, 2, 1, 7, colors.barColor) + draw.rect(GPU, 7, 2, 21, 1, colors.barColor) return maintenanceIndex end @@ -61,50 +56,50 @@ function widgets.gtMachine(GPU, name, address) local barAmount = currentProgress --First Straight _, f, _ = GPU.get(3, 1) - if f ~= mainColor then + if f ~= colors.mainColor then local bars1 = math.max(0, math.min(3, barAmount)) - draw.rect(GPU, 3, 2, 3, 1, barColor) - draw.rect(GPU, 24, 8, 3, 1, barColor) - draw.rect(GPU, 2, 2, 1, 7, barColor) - draw.rect(GPU, 27, 2, 1, 7, barColor) - draw.rect(GPU, 3, 8, 20, 1, barColor) - draw.rect(GPU, 7, 2, 20, 1, barColor) - draw.rect(GPU, 6 - bars1, 2, bars1, 1, mainColor) - draw.rect(GPU, 24, 8, bars1, 1, mainColor) + draw.rect(GPU, 3, 2, 3, 1, colors.barColor) + draw.rect(GPU, 24, 8, 3, 1, colors.barColor) + draw.rect(GPU, 2, 2, 1, 7, colors.barColor) + draw.rect(GPU, 27, 2, 1, 7, colors.barColor) + draw.rect(GPU, 3, 8, 20, 1, colors.barColor) + draw.rect(GPU, 7, 2, 20, 1, colors.barColor) + draw.rect(GPU, 6 - bars1, 2, bars1, 1, colors.mainColor) + draw.rect(GPU, 24, 8, bars1, 1, colors.mainColor) end _, f, _ = GPU.get(2, 4) - if barAmount > 3 and f ~= mainColor then --Vertical + if barAmount > 3 and f ~= colors.mainColor then --Vertical bars2 = math.max(0, math.min(7, barAmount - 3)) - draw.rect(GPU, 2, 2, 1, 7, barColor) - draw.rect(GPU, 27, 2, 1, 7, barColor) - draw.rect(GPU, 3, 8, 20, 1, barColor) - draw.rect(GPU, 7, 2, 20, 1, barColor) - draw.rect(GPU, 2, 2, 1, bars2, mainColor) - draw.rect(GPU, 27, 9 - bars2, 1, bars2, mainColor) + draw.rect(GPU, 2, 2, 1, 7, colors.barColor) + draw.rect(GPU, 27, 2, 1, 7, colors.barColor) + draw.rect(GPU, 3, 8, 20, 1, colors.barColor) + draw.rect(GPU, 7, 2, 20, 1, colors.barColor) + draw.rect(GPU, 2, 2, 1, bars2, colors.mainColor) + draw.rect(GPU, 27, 9 - bars2, 1, bars2, colors.mainColor) end if barAmount > 10 then --Long Straight local bars3 = math.max(0, barAmount - 10) - draw.rect(GPU, 3, 8, 20, 1, barColor) - draw.rect(GPU, 7, 2, 20, 1, barColor) - draw.rect(GPU, 3, 8, bars3, 1, mainColor) - draw.rect(GPU, 27 - bars3, 2, bars3, 1, mainColor) + draw.rect(GPU, 3, 8, 20, 1, colors.barColor) + draw.rect(GPU, 7, 2, 20, 1, colors.barColor) + draw.rect(GPU, 3, 8, bars3, 1, colors.mainColor) + draw.rect(GPU, 27 - bars3, 2, bars3, 1, colors.mainColor) end progressString = tostring(math.floor(machine.getWorkProgress() / 20)) .. "/" .. tostring(math.floor(machine.getWorkMaxProgress() / 20)) .. "s" middlePoint = math.min(9, 12 - #progressString / 2) - draw.rect(GPU, 18, 5, 8, 2, background) - draw.text(GPU, 26 - #progressString, 5, accentA, progressString) + draw.rect(GPU, 18, 5, 8, 2, colors.background) + draw.text(GPU, 26 - #progressString, 5, colors.accentA, progressString) else --No work _, f, _ = GPU.get(5, 1) - if f ~= barColor then - draw.rect(GPU, 18, 5, 8, 2, background) - draw.rect(GPU, 3, 2, 3, 1, barColor) - draw.rect(GPU, 2, 2, 1, 7, barColor) - draw.rect(GPU, 3, 8, 20, 1, barColor) - draw.rect(GPU, 24, 8, 3, 1, barColor) - draw.rect(GPU, 27, 2, 1, 7, barColor) - draw.rect(GPU, 7, 2, 20, 1, barColor) + if f ~= colors.barColor then + draw.rect(GPU, 18, 5, 8, 2, colors.background) + draw.rect(GPU, 3, 2, 3, 1, colors.barColor) + draw.rect(GPU, 2, 2, 1, 7, colors.barColor) + draw.rect(GPU, 3, 8, 20, 1, colors.barColor) + draw.rect(GPU, 24, 8, 3, 1, colors.barColor) + draw.rect(GPU, 27, 2, 1, 7, colors.barColor) + draw.rect(GPU, 7, 2, 20, 1, colors.barColor) end end _, f, _ = GPU.get(6, 1) @@ -112,20 +107,20 @@ function widgets.gtMachine(GPU, name, address) ((windows[name].data == 0 or string.match(machine.getSensorInformation()[windows[name].data], ".*c0.*")) and machine.isWorkAllowed()) == true then - if f ~= background then - draw.rect(GPU, 6, 2, 1, 1, background) - draw.rect(GPU, 23, 8, 1, 1, background) + if f ~= colors.background then + draw.rect(GPU, 6, 2, 1, 1, colors.background) + draw.rect(GPU, 23, 8, 1, 1, colors.background) end else if (machine.isWorkAllowed()) then - if f ~= accentA then - draw.rect(GPU, 6, 2, 1, 1, accentA) - draw.rect(GPU, 23, 8, 1, 1, accentA) + if f ~= colors.accentA then + draw.rect(GPU, 6, 2, 1, 1, colors.accentA) + draw.rect(GPU, 23, 8, 1, 1, colors.accentA) end else - if f ~= errorColor then - draw.rect(GPU, 6, 2, 1, 1, errorColor) - draw.rect(GPU, 23, 8, 1, 1, errorColor) + if f ~= colors.errorColor then + draw.rect(GPU, 6, 2, 1, 1, colors.errorColor) + draw.rect(GPU, 23, 8, 1, 1, colors.errorColor) end end end diff --git a/Libraries/network.lua b/Libraries/Network/network.lua similarity index 100% rename from Libraries/network.lua rename to Libraries/Network/network.lua diff --git a/monitor-system/src/api/sound/play-tune.lua b/Libraries/Sound/play-tune.lua similarity index 96% rename from monitor-system/src/api/sound/play-tune.lua rename to Libraries/Sound/play-tune.lua index a2cdb50..b56b27e 100644 --- a/monitor-system/src/api/sound/play-tune.lua +++ b/Libraries/Sound/play-tune.lua @@ -1,5 +1,5 @@ -- Import section -local computer = require("computer") +computer = require("computer") -- local notes = { diff --git a/monitor-system/src/util/class/inherits.lua b/Libraries/Utilities/inherits.lua similarity index 100% rename from monitor-system/src/util/class/inherits.lua rename to Libraries/Utilities/inherits.lua diff --git a/monitor-system/src/util/class/new.lua b/Libraries/Utilities/new.lua similarity index 100% rename from monitor-system/src/util/class/new.lua rename to Libraries/Utilities/new.lua diff --git a/monitor-system/src/util/parser.lua b/Libraries/Utilities/parser.lua similarity index 100% rename from monitor-system/src/util/parser.lua rename to Libraries/Utilities/parser.lua diff --git a/Libraries/utility.lua b/Libraries/Utilities/utility.lua similarity index 100% rename from Libraries/utility.lua rename to Libraries/Utilities/utility.lua diff --git a/Libraries/config.lua b/Libraries/config.lua deleted file mode 100644 index 4789e72..0000000 --- a/Libraries/config.lua +++ /dev/null @@ -1,11 +0,0 @@ -machineBackground = 0x121010 -progressBackground = 0x272c2e -labelColor = 0xFF00FF -errorColor = 0xFF0000 -idleColor = 0xb300ff -workingColor = 0x00a6ff -positiveEUColor = 0x00CC00 -negativeEUColor = 0xCC0000 -timeColor = 0x5500FF -textColor = 0x000000 -hudColor = 0x1E1E28 diff --git a/Programs/Autostocker/stocker.lua b/Programs/Autostocker/stocker.lua index 7c8b376..28f5392 100644 --- a/Programs/Autostocker/stocker.lua +++ b/Programs/Autostocker/stocker.lua @@ -32,7 +32,7 @@ function mouseListener() currentWindows["Button"].y * 2 + 1, 6, 6, - negativeEUColor + colors.negativeEUColor ) else G.rect( @@ -41,7 +41,7 @@ function mouseListener() currentWindows["Button"].y * 2 + 1, 6, 6, - positiveEUColor + colors.positiveEUColor ) if itemsToStock[drawerItem] ~= nil then S.update(drawerItem, itemsToStock[drawerItem], number) @@ -97,7 +97,7 @@ function keyboardListener() number = number .. value end G.rect(GPU, currentWindows["Number"].x + 2, currentWindows["Number"].y * 2 + 1, 46, 6, 0x333333) - G.text(GPU, currentWindows["Number"].x + 4, currentWindows["Number"].y * 2 + 3, workingColor, number) + G.text(GPU, currentWindows["Number"].x + 4, currentWindows["Number"].y * 2 + 3, colors.workingColor, number) end end return event.listen("key_down", processKey) @@ -108,25 +108,25 @@ function getNewItem(GPU, x, y) currentWindows["Item"].x = x currentWindows["Item"].y = y GPU.setActiveBuffer(itemWindow) - G.rect(GPU, 2, 2, 58, 4, hudColor) + G.rect(GPU, 2, 2, 58, 4, colors.hudColor) G.rect(GPU, 3, 3, 56, 2, 0x000000) GPU.setActiveBuffer(0) end local newDrawerItem = transposer.getStackInSlot(sides.top, 2) if newDrawerItem ~= nil then if craftables[newDrawerItem] ~= nil then - GPU.setForeground(workingColor) + GPU.setForeground(colors.workingColor) else - GPU.setActiveBuffer(negativeEUColor) + GPU.setActiveBuffer(colors.negativeEUColor) end if drawerItem == nil then drawerItem = newDrawerItem.label GPU.setActiveBuffer(currentWindows["Item"].page) G.rect(GPU, 3, 3, 56, 2, 0x000000) if craftables[drawerItem] ~= nil then - G.centeredText(GPU, 30, 3, positiveEUColor, drawerItem) + G.centeredText(GPU, 30, 3, colors.positiveEUColor, drawerItem) else - G.centeredText(GPU, 30, 3, negativeEUColor, drawerItem) + G.centeredText(GPU, 30, 3, colors.negativeEUColor, drawerItem) end GPU.setActiveBuffer(0) if itemsToStock[drawerItem] ~= nil then @@ -146,9 +146,9 @@ function getNewItem(GPU, x, y) GPU.setActiveBuffer(currentWindows["Item"].page) G.rect(GPU, 3, 3, 56, 2, 0x000000) if craftables[drawerItem] ~= nil then - G.centeredText(GPU, 30, 3, positiveEUColor, drawerItem) + G.centeredText(GPU, 30, 3, colors.positiveEUColor, drawerItem) else - G.centeredText(GPU, 30, 3, negativeEUColor, drawerItem) + G.centeredText(GPU, 30, 3, colors.negativeEUColor, drawerItem) end GPU.setActiveBuffer(0) if itemsToStock[drawerItem] ~= nil then @@ -182,7 +182,7 @@ function numberBox(GPU, x, y) currentWindows["Number"].x = x currentWindows["Number"].y = y GPU.setActiveBuffer(itemWindow) - G.rect(GPU, 2, 2, 48, 8, hudColor) + G.rect(GPU, 2, 2, 48, 8, colors.hudColor) G.rect(GPU, 3, 3, 46, 6, 0x000000) GPU.setActiveBuffer(0) end @@ -193,8 +193,8 @@ function button(GPU, x, y) currentWindows["Button"].x = x currentWindows["Button"].y = y GPU.setActiveBuffer(button) - G.rect(GPU, 2, 2, 8, 8, hudColor) - G.rect(GPU, 3, 3, 6, 6, workingColor) + G.rect(GPU, 2, 2, 8, 8, colors.hudColor) + G.rect(GPU, 3, 3, 6, 6, colors.workingColor) GPU.setActiveBuffer(0) end end @@ -204,12 +204,12 @@ function craftableBox(GPU, x, y) currentWindows["Craft"].x = x currentWindows["Craft"].y = y GPU.setActiveBuffer(crafts) - G.rect(GPU, 2, 2, 70, 94, hudColor) + G.rect(GPU, 2, 2, 70, 94, colors.hudColor) GPU.setActiveBuffer(0) end GPU.setActiveBuffer(currentWindows["Craft"].page) G.rect(GPU, 3, 4, 68, 90, 0x000000) - G.rect(GPU, 48, 2, 1, 94, hudColor) + G.rect(GPU, 48, 2, 1, 94, colors.hudColor) local i = 1 S.updateCache() for label, amount in pairs(itemsToStock) do @@ -219,16 +219,16 @@ function craftableBox(GPU, x, y) if S.uniques() > 2500 then --Check against rebooted system if toStock > 0 then if drawerItem == label then - G.text(GPU, 4, 3 + 2 * i, workingColor, label) + G.text(GPU, 4, 3 + 2 * i, colors.workingColor, label) elseif craftables[label] == nil then - G.text(GPU, 4, 3 + 2 * i, negativeEUColor, label) + G.text(GPU, 4, 3 + 2 * i, colors.negativeEUColor, label) else G.text(GPU, 4, 3 + 2 * i, 0xFFFFFF, label) end if stockedAmount >= toStock then --In stock G.text(GPU, 59 - (#stockedString + 1), 3 + 2 * i, 0xFFFFFF, stockedString) elseif stockedAmount >= toStock * 0.85 then --Edit hysteresis here, slightly below stock - G.text(GPU, 59 - (#stockedString + 1), 3 + 2 * i, workingColor, stockedString) + G.text(GPU, 59 - (#stockedString + 1), 3 + 2 * i, colors.workingColor, stockedString) else --Needs to be ordered --Add crafting request loop here if craftables[label] ~= nil then @@ -238,7 +238,7 @@ function craftableBox(GPU, x, y) currentlyCrafting[label] = nil end end - G.text(GPU, 59 - (#stockedString + 1), 3 + 2 * i, negativeEUColor, stockedString) + G.text(GPU, 59 - (#stockedString + 1), 3 + 2 * i, colors.negativeEUColor, stockedString) end G.text(GPU, 59, 3 + 2 * i, 0xFFFFFF, "| " .. amount) i = math.min(i + 1, 43) diff --git a/monitor-system/src/data/datasource/energy-provider.lua b/Programs/monitor-system/src/data/datasource/energy-provider.lua similarity index 96% rename from monitor-system/src/data/datasource/energy-provider.lua rename to Programs/monitor-system/src/data/datasource/energy-provider.lua index 945e58e..421d74f 100755 --- a/monitor-system/src/data/datasource/energy-provider.lua +++ b/Programs/monitor-system/src/data/datasource/energy-provider.lua @@ -2,7 +2,7 @@ local parser = require("util.parser") local inherits = require("util.class.inherits") local SingleBlock = require("data.datasource.single-block") -local mock = require("data.mock.mock-energy-provider") +local mock = require("mock-energy-provider") -- local EnergyProvider = diff --git a/monitor-system/src/data/datasource/miner.lua b/Programs/monitor-system/src/data/datasource/miner.lua similarity index 100% rename from monitor-system/src/data/datasource/miner.lua rename to Programs/monitor-system/src/data/datasource/miner.lua diff --git a/monitor-system/src/data/datasource/multi-block.lua b/Programs/monitor-system/src/data/datasource/multi-block.lua similarity index 92% rename from monitor-system/src/data/datasource/multi-block.lua rename to Programs/monitor-system/src/data/datasource/multi-block.lua index eb07b14..079068f 100755 --- a/monitor-system/src/data/datasource/multi-block.lua +++ b/Programs/monitor-system/src/data/datasource/multi-block.lua @@ -2,7 +2,7 @@ local parser = require("util.parser") local inherits = require("util.class.inherits") local SingleBlock = require("data.datasource.single-block") -local mock = require("data.mock.mock-multi-block") +local mock = require("mock-multi-block") -- local MultiBlock = diff --git a/monitor-system/src/data/datasource/single-block.lua b/Programs/monitor-system/src/data/datasource/single-block.lua similarity index 97% rename from monitor-system/src/data/datasource/single-block.lua rename to Programs/monitor-system/src/data/datasource/single-block.lua index aa40920..29529f5 100644 --- a/monitor-system/src/data/datasource/single-block.lua +++ b/Programs/monitor-system/src/data/datasource/single-block.lua @@ -1,6 +1,6 @@ -- Import section local component = require("component") -local mock = require("data.mock.mock-single-block") +local mock = require("mock-single-block") -- local SingleBlock = { diff --git a/monitor-system/src/domain/cleanroom/protect-recipes-usecase.lua b/Programs/monitor-system/src/domain/cleanroom/protect-recipes-usecase.lua similarity index 100% rename from monitor-system/src/domain/cleanroom/protect-recipes-usecase.lua rename to Programs/monitor-system/src/domain/cleanroom/protect-recipes-usecase.lua diff --git a/monitor-system/src/domain/energy/get-energy-status-usecase.lua b/Programs/monitor-system/src/domain/energy/get-energy-status-usecase.lua similarity index 82% rename from monitor-system/src/domain/energy/get-energy-status-usecase.lua rename to Programs/monitor-system/src/domain/energy/get-energy-status-usecase.lua index fe1ad6a..5a6ee5e 100755 --- a/monitor-system/src/domain/energy/get-energy-status-usecase.lua +++ b/Programs/monitor-system/src/domain/energy/get-energy-status-usecase.lua @@ -9,13 +9,11 @@ local function exec(energyProducers, energyBuffer) local consumption = energyBuffer:getAverageInput() local production = energyBuffer:getAverageOutput() local energyCapacity = energyBuffer:getTotalEnergy().maximum - local timeToFull = energyCapacity / (production - consumption) - local timetoEmpty = -timeToFull + local timeToFull = (production - consumption) ~= 0 and energyCapacity / (production - consumption) or "-" return { consumption = consumption, production = production, timeToFull = timeToFull, - timetoEmpty = timetoEmpty } end diff --git a/monitor-system/src/init.lua b/Programs/monitor-system/src/init.lua similarity index 72% rename from monitor-system/src/init.lua rename to Programs/monitor-system/src/init.lua index 1d5b426..4da7768 100755 --- a/monitor-system/src/init.lua +++ b/Programs/monitor-system/src/init.lua @@ -1,13 +1,14 @@ -- Import section -Computer = require("computer") -Component = require("component") +computer = require("computer") +comp = require("component") MultiBlock = require("data.datasource.multi-block") SingleBlock = require("data.datasource.single-block") EnergyProvider = require("data.datasource.energy-provider") -local cleanroomAddresses = require("data.database.cleanroom") -local multiBlockAddresses = require("data.database.multi-blocks") -local energyBufferAddress = require("data.database.energy-buffer") +local cleanroomAddresses = require("cleanroom") +local multiBlockAddresses = require("multi-blocks") +local energyBufferAddress = require("energy-buffer") + local protectCleanroomRecipes = require("domain.cleanroom.protect-recipes-usecase") local getMultiblockStatuses = require("domain.multiblock.get-status-usecase") local getEnergyStatus = require("domain.energy.get-energy-status-usecase") @@ -15,7 +16,7 @@ local getEnergyStatus = require("domain.energy.get-energy-status-usecase") local cleanroom = MultiBlock:new(multiBlockAddresses.cleanroom) local cleanroomMachines = {} -for address in pairs(cleanroomAddresses.machines) do +for _, address in pairs(cleanroomAddresses) do table.insert(cleanroomMachines, SingleBlock:new(address)) end @@ -27,11 +28,7 @@ local energyBuffer = EnergyProvider:new(energyBufferAddress) local energyProducers = {} -local i = 1 -while true do - if (i > 100) then - break - end +for i = 0, 100 do print(i) protectCleanroomRecipes(cleanroom, cleanroomMachines) local multiblockStatuses = getMultiblockStatuses(multiblocks) diff --git a/monitor-system/src/data/mock/mock-energy-provider.lua b/Resources/Mock/mock-energy-provider.lua similarity index 100% rename from monitor-system/src/data/mock/mock-energy-provider.lua rename to Resources/Mock/mock-energy-provider.lua diff --git a/monitor-system/src/data/mock/mock-multi-block.lua b/Resources/Mock/mock-multi-block.lua similarity index 100% rename from monitor-system/src/data/mock/mock-multi-block.lua rename to Resources/Mock/mock-multi-block.lua diff --git a/monitor-system/src/data/mock/mock-single-block.lua b/Resources/Mock/mock-single-block.lua similarity index 100% rename from monitor-system/src/data/mock/mock-single-block.lua rename to Resources/Mock/mock-single-block.lua diff --git a/monitor-system/src/api/sound/alarm.lua b/Resources/sound/alarm.lua similarity index 89% rename from monitor-system/src/api/sound/alarm.lua rename to Resources/sound/alarm.lua index d6d8e2c..3ea1d69 100755 --- a/monitor-system/src/api/sound/alarm.lua +++ b/Resources/sound/alarm.lua @@ -1,5 +1,5 @@ -- Import section -local playTune = require("api.sound.play-tune") +local playTune = require("play-tune") -- local tune = { diff --git a/monitor-system/src/api/sound/mario-one-up.lua b/Resources/sound/mario-one-up.lua similarity index 69% rename from monitor-system/src/api/sound/mario-one-up.lua rename to Resources/sound/mario-one-up.lua index 5b55b2c..83d55e6 100755 --- a/monitor-system/src/api/sound/mario-one-up.lua +++ b/Resources/sound/mario-one-up.lua @@ -1,5 +1,5 @@ -- Import section -local playTune = require("api.sound.play-tune") +local playTune = require("play-tune") -- local tune = { diff --git a/monitor-system/src/api/sound/zelda-secret.lua b/Resources/sound/zelda-secret.lua similarity index 72% rename from monitor-system/src/api/sound/zelda-secret.lua rename to Resources/sound/zelda-secret.lua index 40ca20f..e38416d 100755 --- a/monitor-system/src/api/sound/zelda-secret.lua +++ b/Resources/sound/zelda-secret.lua @@ -1,5 +1,5 @@ -- Import section -local playTune = require('api.sound.play-tune') +local playTune = require('play-tune') -- local tune = { diff --git a/monitor-system/src/domain/energy/get-consumption-usecase.lua b/monitor-system/src/domain/energy/get-consumption-usecase.lua deleted file mode 100755 index cee327a..0000000 --- a/monitor-system/src/domain/energy/get-consumption-usecase.lua +++ /dev/null @@ -1,2 +0,0 @@ -return function (arg1, arg2, arg3) -end \ No newline at end of file diff --git a/monitor-system/src/domain/energy/get-production-usecase.lua b/monitor-system/src/domain/energy/get-production-usecase.lua deleted file mode 100755 index e0bf71d..0000000 --- a/monitor-system/src/domain/energy/get-production-usecase.lua +++ /dev/null @@ -1,3 +0,0 @@ -return function (arg1, arg2, arg3) - -end \ No newline at end of file diff --git a/monitor-system/src/domain/multiblock/get-status-usecase.lua b/monitor-system/src/domain/multiblock/get-status-usecase.lua deleted file mode 100755 index e0bf71d..0000000 --- a/monitor-system/src/domain/multiblock/get-status-usecase.lua +++ /dev/null @@ -1,3 +0,0 @@ -return function (arg1, arg2, arg3) - -end \ No newline at end of file