Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MonitorSide = "bottom"
- DMGenerationColour = colours.orange
- DMGenDisabledColour = colours.magenta
- RedstoneInputSide = "top"
- 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)
- local textLength = string.len(text)
- local centerX = (width / 2) - (textLength / 2)
- DrawText(xPos + centerX, yPos, text, textColour, backgroundColour)
- end
- function DMGeneratorIsOnline()
- local inColours = redstone.getBundledInput(RedstoneInputSide)
- return colours.test(inColours, DMGenerationColour)
- end
- function IsDisabled()
- local inColours = redstone.getBundledInput(RedstoneInputSide)
- return colours.test(inColours, DMGenDisabledColour) == false
- end
- function Main()
- while true do
- Monitor.setTextScale(3)
- local w, h = Monitor.getSize()
- if (DMGeneratorIsOnline()) then
- Monitor.setBackgroundColor(colours.green)
- Monitor.setTextColor(colours.green)
- Monitor.clear()
- DrawCenteredHorizontal(2, 2, w - 2, "DM Generator", colours.white, colours.green)
- DrawCenteredHorizontal(2, 5, w - 2, "ONLINE", colours.white, colours.green)
- else
- if (IsDisabled()) then
- Monitor.setBackgroundColor(colours.red)
- Monitor.setTextColor(colours.red)
- Monitor.clear()
- DrawCenteredHorizontal(2, 2, w - 2, "DM Generator", colours.white, colours.red)
- DrawCenteredHorizontal(2, 4, w - 2, "-- EMERGENCY --", colours.white, colours.red)
- DrawCenteredHorizontal(2, 5, w - 2, "-- DISABLED --", colours.white, colours.red)
- else
- Monitor.setBackgroundColor(colours.orange)
- Monitor.setTextColor(colours.orange)
- Monitor.clear()
- DrawCenteredHorizontal(2, 2, w - 2, "DM Generator", colours.white, colours.orange)
- DrawCenteredHorizontal(2, 5, w - 2, "OFFLINE", colours.white, colours.orange)
- end
- end
- os.sleep(1)
- end
- end
- Main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement