Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- InputSignalDirection = "top"
- MonitorSide = "bottom"
- Monitor = peripheral.wrap(MonitorSide)
- RedstoneIOSide = "top"
- StopFunction = ""
- function DrawText(xPos, yPos, text, textColour, backgroundColour)
- Monitor.setBackgroundColor(backgroundColour)
- Monitor.setTextColor(textColour)
- Monitor.setCursorPos(xPos,yPos)
- Monitor.write(text)
- end
- function FillBackground(colour)
- Monitor.setBackgroundColor(colour)
- Monitor.clear()
- end
- function DrawCenteredHorizontal(yPos, text, textColour, backgroundColour)
- local monX, monY = Monitor.getSize()
- local textLength = string.len(text)
- local centerX = (monX / 2) - (textLength / 2)
- DrawText(centerX, yPos, text, textColour, backgroundColour)
- end
- function Draw()
- while true do
- local inputColours = redstone.getBundledInput(RedstoneIOSide)
- local isActive = colours.test(inputColours, colours.white)
- if (isActive) then
- FillBackground(colours.green)
- DrawCenteredHorizontal(2, "Dark Matter Generator", colours.white, colours.green)
- DrawCenteredHorizontal(4, "ONLINE", colours.white, colours.green)
- else
- FillBackground(colours.red)
- DrawCenteredHorizontal(2, "Dark Matter Generator", colours.white, colours.red)
- DrawCenteredHorizontal(4, "OFFLINE", colours.white, colours.red)
- end
- os.sleep(0.8)
- end
- end
- function WaitForMonitorTouch()
- local event, side, x, y = os.pullEvent("monitor_touch")
- --TouchX = x
- --TouchY = y
- StopFunction = "monTouch"
- end
- function MonitorTouched()
- local outputColours = redstone.getBundledOutput(RedstoneIOSide)
- if (colours.test(outputColours, colours.white)) then
- redstone.setBundledOutput(RedstoneIOSide, outputColours - colours.white)
- else
- redstone.setBundledOutput(RedstoneIOSide, outputColours + colours.white)
- end
- return
- 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