Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MonitorSide = "monitor_56"
- Monitor = peripheral.wrap(MonitorSide)
- function ClearMonitor()
- Monitor.setTextColor(colours.black)
- Monitor.setBackgroundColor(colours.black)
- Monitor.clear()
- Monitor.setCursorPos(1,1)
- end
- function DrawText(xPos, yPos, text, textColour, backgroundColour)
- Monitor.setBackgroundColor(backgroundColour)
- Monitor.setTextColor(textColour)
- Monitor.setCursorPos(xPos,yPos)
- Monitor.write(text)
- end
- function DrawCenteredHorizontal(xPos, yPos, width, text, textColour, backgroundColour)
- -- width could be the size of your monitor, or anything else. this means it
- -- doesn't have to stretch your entire monitor's if you want. imagine
- -- it as a rectangle and the text is in the center.
- local textLength = string.len(text)
- local centerX = (width / 2) - (textLength / 2)
- DrawText(xPos + centerX, yPos, text, textColour, backgroundColour)
- end
- function DrawLineH(xPos, yPos, lineLength, colour)
- Monitor.setBackgroundColor(colour)
- Monitor.setTextColor(colour)
- Monitor.setCursorPos(xPos,yPos)
- Monitor.write(string.rep(" ", lineLength))
- end
- function DrawLineV(xPos, yPos, width, lineHeight, colour)
- Monitor.setBackgroundColor(colour)
- for i = 1, lineHeight, 1 do
- Monitor.setCursorPos(xPos, yPos + (i - 1))
- Monitor.write(string.rep(" ", width))
- end
- end
- function DrawSquare(xPos, yPos, nWidth, nHeight, backgroundColour)
- Monitor.setBackgroundColor(backgroundColour)
- for i = 1, math.ceil(nHeight), 1 do
- Monitor.setCursorPos(xPos, yPos + (i - 1))
- Monitor.write(string.rep(" ", nWidth))
- end
- end
- function ProgressBar(xPos, yPos, width, value, maxValue, backgroundColour, progressColour)
- DrawLineH(xPos, yPos, width, backgroundColour) --backgoround bar
- local barSize = math.floor((value/maxValue) * width)
- DrawLineH(xPos, yPos, barSize, progressColour) --progress so far
- end
- function GroupBoxHeader(xPos, yPos, width, header, textColour, backgroundColour)
- local headerLength = string.len(header)
- local repeatChars = width - 4 - headerLength - 1
- if (repeatChars < 0) then
- repeatChars = 0
- end
- local head = "--- " .. header .. " " .. string.rep("-", repeatChars)
- DrawText(xPos, yPos, head, textColour, backgroundColour)
- end
- function GroupBoxFooter(xPos, yPos, width, textColour, backgroundColour)
- if (width < 0) then
- width = 0
- end
- local head = string.rep("-", width)
- DrawText(xPos, yPos, head, textColour, backgroundColour)
- end
- function GroupBox(xPos, yPos, width, height, header, textColour, headerBackgroundColour)
- GroupBoxHeader(xPos, yPos, width, header, textColour, headerBackgroundColour)
- GroupBoxFooter(xPos, yPos + height + 1, width, textColour, headerBackgroundColour)
- end
- FusionControlsInputSide = "bottom"
- Fusion1Colour = colours.white
- Fusion2Colour = colours.orange
- Fusion3Colour = colours.magenta
- Fusion4Colour = colours.lightBlue
- FuelGeneratorInputColour = colours.yellow
- FusionControlsOutputSide = "right"
- ActiveFusionColours = 0
- FuelGenerationOutputSide = "back"
- FuelGeneratorOutputColour = colours.white
- function CheckFCINColourActive(colour)
- return colours.test(redstone.getBundledInput(FusionControlsInputSide), colour)
- end
- function IsFusion1On()
- return CheckFCINColourActive(Fusion1Colour)
- end
- function IsFusion2On()
- return CheckFCINColourActive(Fusion2Colour)
- end
- function IsFusion3On()
- return CheckFCINColourActive(Fusion3Colour)
- end
- function IsFusion4On()
- return CheckFCINColourActive(Fusion4Colour)
- end
- function StatusToColour(isActive)
- if (isActive) then
- return colours.green
- else
- return colours.red
- end
- end
- function UpdateFusion1()
- if (IsFusion1On()) then
- if (colours.test(ActiveFusionColours, Fusion1Colour) == false) then
- ActiveFusionColours = ActiveFusionColours + Fusion1Colour
- end
- else
- if (colours.test(ActiveFusionColours, Fusion1Colour)) then
- ActiveFusionColours = ActiveFusionColours - Fusion1Colour
- end
- end
- end
- function UpdateFusion2()
- if (IsFusion2On()) then
- if (colours.test(ActiveFusionColours, Fusion2Colour) == false) then
- ActiveFusionColours = ActiveFusionColours + Fusion2Colour
- end
- else
- if (colours.test(ActiveFusionColours, Fusion2Colour)) then
- ActiveFusionColours = ActiveFusionColours - Fusion2Colour
- end
- end
- end
- function UpdateFusion3()
- if (IsFusion3On()) then
- if (colours.test(ActiveFusionColours, Fusion3Colour) == false) then
- ActiveFusionColours = ActiveFusionColours + Fusion3Colour
- end
- else
- if (colours.test(ActiveFusionColours, Fusion3Colour)) then
- ActiveFusionColours = ActiveFusionColours - Fusion3Colour
- end
- end
- end
- function UpdateFusion4()
- if (IsFusion4On()) then
- if (colours.test(ActiveFusionColours, Fusion4Colour) == false) then
- ActiveFusionColours = ActiveFusionColours + Fusion4Colour
- end
- else
- if (colours.test(ActiveFusionColours, Fusion4Colour)) then
- ActiveFusionColours = ActiveFusionColours - Fusion4Colour
- end
- end
- end
- function ActivateReactors()
- redstone.setBundledOutput(FusionControlsOutputSide, ActiveFusionColours)
- end
- function DrawFusionReactor()
- local yPos = 2
- local xPos = 2
- local frW = 20
- local frH = 17
- local frbW = 4
- local frbH = 3
- local blcW = 2
- local blcH = 1
- DrawLineH(xPos + blcW , yPos, frW, colours.orange)
- DrawLineH(xPos + blcW , frH , frW, colours.orange)
- DrawLineV(xPos , yPos + blcH, blcW, frH - blcH - yPos, colours.orange)
- DrawLineV(xPos + frW + blcW, yPos + blcH, blcW, frH - blcH - yPos, colours.orange)
- -- 1 3
- -- 2 4
- DrawSquare(xPos + blcW + frbW, yPos + frbH , frbW, frbH, StatusToColour(IsFusion1On()))
- DrawSquare(xPos + blcW + frbW, yPos + (frbH * 3), frbW, frbH, StatusToColour(IsFusion2On()))
- DrawSquare(xPos + blcW + (frbW * 3), yPos + frbH , frbW, frbH, StatusToColour(IsFusion3On()))
- DrawSquare(xPos + blcW + (frbW * 3), yPos + (frbH * 3), frbW, frbH, StatusToColour(IsFusion4On()))
- end
- function DrawFusion1(xPos, yPos)
- if (IsFusion1On()) then
- DrawText(xPos, yPos, "ONLINE", colours.white, colours.green)
- else
- DrawText(xPos, yPos, "OFFLINE", colours.white, colours.red)
- end
- end
- function DrawFusion2(xPos, yPos)
- if (IsFusion2On()) then
- DrawText(xPos, yPos, "ONLINE", colours.white, colours.green)
- else
- DrawText(xPos, yPos, "OFFLINE", colours.white, colours.red)
- end
- end
- function DrawFusion3(xPos, yPos)
- if (IsFusion3On()) then
- DrawText(xPos, yPos, "ONLINE", colours.white, colours.green)
- else
- DrawText(xPos, yPos, "OFFLINE", colours.white, colours.red)
- end
- end
- function DrawFusion4(xPos, yPos)
- if (IsFusion4On()) then
- DrawText(xPos, yPos, "ONLINE", colours.white, colours.green)
- else
- DrawText(xPos, yPos, "OFFLINE", colours.white, colours.red)
- end
- end
- function IsFuelGeneratorOn()
- return colours.test(redstone.getBundledInput(FusionControlsInputSide, FuelGeneratorInputColour), FuelGeneratorInputColour)
- end
- function Main()
- local gbWidth = 18
- while true do
- -- Draw reactor squares
- local w, h = Monitor.getSize()
- UpdateFusion1()
- UpdateFusion2()
- UpdateFusion3()
- UpdateFusion4()
- ActivateReactors()
- ClearMonitor()
- DrawFusionReactor()
- DrawText(28, 2, "Fusion 1 - ", colours.white, colours.black)
- DrawText(28, 4, "Fusion 2 - ", colours.white, colours.black)
- DrawText(28, 6, "Fusion 3 - ", colours.white, colours.black)
- DrawText(28, 8, "Fusion 4 - ", colours.white, colours.black)
- DrawFusion1(39, 2)
- DrawFusion2(39, 4)
- DrawFusion3(39, 6)
- DrawFusion4(39, 8)
- GroupBox(28, 10, 24, 9, "Fuel Generator", colours.yellow, colours.black)
- if (IsFuelGeneratorOn()) then
- redstone.setBundledOutput(FuelGenerationOutputSide, FuelGeneratorOutputColour)
- DrawSquare(28, 12, 24, 7, colours.green)
- DrawCenteredHorizontal(28, 15, 24, "ONLINE", colours.white, colours.green)
- else
- redstone.setBundledOutput(FuelGenerationOutputSide, 0)
- DrawSquare(28, 12, 24, 7, colours.red)
- DrawCenteredHorizontal(28, 15, 24, "OFFLINE", colours.white, colours.red)
- end
- sleep(0.5)
- end
- end
- Main()
RAW Paste Data