Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MonitorSide = "right"
- RedstoneInputSide = "back"
- Monitor = peripheral.wrap(MonitorSide)
- TouchX = 0
- TouchY = 0
- StopFunction = ""
- 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 GroupBoxHeader(xPos, yPos, width, header, textColour, backgroundColour)
- local headerLength = string.len(header)
- local repeatChars = width - 4 - headerLength
- 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
- function DrawStatus(xPos, yPos, isActive)
- if (isActive) then
- DrawText(xPos, yPos, "ONLINE", colours.white, colours.green)
- else
- DrawText(xPos, yPos, "OFFLINE", colours.white, colours.red)
- end
- end
- function Draw()
- while true do
- local inputColours = redstone.getBundledInput(RedstoneInputSide)
- local moon = colours.test(inputColours, colours.white)
- local base2 = colours.test(inputColours, colours.orange)
- local bridge = colours.test(inputColours, colours.magenta)
- local mars = colours.test(inputColours, colours.lightBlue)
- local w, h = Monitor.getSize()
- ClearMonitor()
- GroupBox(2, 2, w, 9, "Quantum Links Info", colours.green, colours.black)
- DrawText(2, 4, "Moon Link:", colours.white, colours.black)
- DrawText(2, 6, "2nd Base Link:", colours.orange, colours.black)
- DrawText(2, 8, "Bridge Link:", colours.magenta, colours.black)
- DrawText(2, 10, "Mars Link:", colours.lightBlue, colours.black)
- DrawStatus(18, 4, moon)
- DrawStatus(18, 6, base2)
- DrawStatus(18, 8, bridge)
- DrawStatus(18, 10, mars)
- sleep(0.5)
- end
- end
- function WaitForMonitorTouch()
- local event, side, x, y = os.pullEvent("monitor_touch")
- TouchX = x
- TouchY = y
- StopFunction = "monTouch"
- end
- function MonitorTouched()
- local x = TouchX
- local y = TouchY
- if (x >= 18 and x <= 25) then
- local outputColours = redstone.getBundledOutput(RedstoneInputSide)
- if (y == 4) then
- if (colours.test(outputColours, colours.white)) then
- redstone.setBundledOutput(RedstoneInputSide, outputColours - colours.white)
- else
- redstone.setBundledOutput(RedstoneInputSide, outputColours + colours.white)
- end
- return
- end
- if (y == 6) then
- if (colours.test(outputColours, colours.orange)) then
- redstone.setBundledOutput(RedstoneInputSide, outputColours - colours.orange)
- else
- redstone.setBundledOutput(RedstoneInputSide, outputColours + colours.orange)
- end
- return
- end
- if (y == 8) then
- if (colours.test(outputColours, colours.magenta)) then
- redstone.setBundledOutput(RedstoneInputSide, outputColours - colours.magenta)
- else
- redstone.setBundledOutput(RedstoneInputSide, outputColours + colours.magenta)
- end
- return
- end
- if (y == 10) then
- if (colours.test(outputColours, colours.lightBlue)) then
- redstone.setBundledOutput(RedstoneInputSide, outputColours - colours.lightBlue)
- else
- redstone.setBundledOutput(RedstoneInputSide, outputColours + colours.lightBlue)
- end
- return
- end
- end
- end
- function Main()
- while true do
- parallel.waitForAny(Draw, WaitForMonitorTouch)
- if (StopFunction == "monTouch") then
- StopFunction = "none"
- MonitorTouched()
- end
- end
- end
- Main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement