bobmarley12345

DMENOFFLNDISABMONITOR

Oct 19th, 2020 (edited)
1,068
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. MonitorSide = "bottom"
  2. DMGenerationColour = colours.orange
  3. DMGenDisabledColour = colours.magenta
  4. RedstoneInputSide = "top"
  5. Monitor = peripheral.wrap(MonitorSide)
  6.  
  7. function ClearMonitor()
  8.     Monitor.setTextColor(colours.black)
  9.     Monitor.setBackgroundColor(colours.black)
  10.     Monitor.clear()
  11.     Monitor.setCursorPos(1,1)
  12. end
  13.  
  14. function DrawText(xPos, yPos, text, textColour, backgroundColour)
  15.     Monitor.setBackgroundColor(backgroundColour)
  16.     Monitor.setTextColor(textColour)
  17.     Monitor.setCursorPos(xPos,yPos)
  18.     Monitor.write(text)
  19. end
  20.  
  21. function DrawCenteredHorizontal(xPos, yPos, width, text, textColour, backgroundColour)
  22.     local textLength = string.len(text)
  23.     local centerX = (width / 2) - (textLength / 2)
  24.     DrawText(xPos + centerX, yPos, text, textColour, backgroundColour)
  25. end
  26.  
  27. function DMGeneratorIsOnline()
  28.     local inColours = redstone.getBundledInput(RedstoneInputSide)
  29.     return colours.test(inColours, DMGenerationColour)
  30. end
  31.  
  32. function IsDisabled()
  33.     local inColours = redstone.getBundledInput(RedstoneInputSide)
  34.     return colours.test(inColours, DMGenDisabledColour) == false
  35. end
  36.  
  37. function Main()
  38.     while true do
  39.         Monitor.setTextScale(3)
  40.         local w, h = Monitor.getSize()
  41.         if (DMGeneratorIsOnline()) then
  42.             Monitor.setBackgroundColor(colours.green)
  43.             Monitor.setTextColor(colours.green)
  44.             Monitor.clear()
  45.             DrawCenteredHorizontal(2, 2, w - 2, "DM Generator", colours.white, colours.green)
  46.             DrawCenteredHorizontal(2, 5, w - 2, "ONLINE", colours.white, colours.green)
  47.         else
  48.             if (IsDisabled()) then
  49.                 Monitor.setBackgroundColor(colours.red)
  50.                 Monitor.setTextColor(colours.red)
  51.                 Monitor.clear()
  52.                 DrawCenteredHorizontal(2, 2, w - 2, "DM Generator", colours.white, colours.red)
  53.                 DrawCenteredHorizontal(2, 4, w - 2, "-- EMERGENCY --", colours.white, colours.red)
  54.                 DrawCenteredHorizontal(2, 5, w - 2, "-- DISABLED  --", colours.white, colours.red)
  55.             else
  56.                 Monitor.setBackgroundColor(colours.orange)
  57.                 Monitor.setTextColor(colours.orange)
  58.                 Monitor.clear()
  59.                 DrawCenteredHorizontal(2, 2, w - 2, "DM Generator", colours.white, colours.orange)
  60.                 DrawCenteredHorizontal(2, 5, w - 2, "OFFLINE", colours.white, colours.orange)
  61.             end
  62.         end
  63.  
  64.         os.sleep(1)
  65.     end
  66. end
  67.  
  68. Main()
RAW Paste Data