Advertisement
bobmarley12345

fusionreactorinfomonitor

Oct 4th, 2020 (edited)
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.52 KB | None | 0 0
  1. MonitorSide = "bottom"
  2. RedstoneIn = "top"
  3. Monitor = peripheral.wrap(MonitorSide)
  4.  
  5. function ClearMonitor()
  6.     Monitor.setTextColor(colours.black)
  7.     Monitor.setBackgroundColor(colours.black)
  8.     Monitor.clear()
  9.     Monitor.setCursorPos(1,1)
  10. end
  11.  
  12. function DrawText(xPos, yPos, text, textColour, backgroundColour)
  13.     Monitor.setBackgroundColor(backgroundColour)
  14.     Monitor.setTextColor(textColour)
  15.     Monitor.setCursorPos(xPos,yPos)
  16.     Monitor.write(text)
  17. end
  18.  
  19. function GroupBoxHeader(xPos, yPos, width, header, textColour, backgroundColour)
  20.     local headerLength = string.len(header)
  21.     local repeatChars = width - 3 - headerLength
  22.  
  23.     if (repeatChars < 0) then
  24.         repeatChars = 0
  25.     end
  26.  
  27.     local head = "-- " .. header .. " " .. string.rep("-", repeatChars)
  28.     DrawText(xPos, yPos, head, textColour, backgroundColour)
  29. end
  30.  
  31. function IsFusion1On()
  32.     return colours.test(redstone.getBundledInput(RedstoneIn), colours.white)
  33. end
  34.  
  35. function IsFusion2On()
  36.     return colours.test(redstone.getBundledInput(RedstoneIn), colours.orange)
  37. end
  38.  
  39. function IsFusion3On()
  40.     return colours.test(redstone.getBundledInput(RedstoneIn), colours.magenta)
  41. end
  42.  
  43. function IsFusion4On()
  44.     return colours.test(redstone.getBundledInput(RedstoneIn), colours.lightBlue)
  45. end
  46.  
  47. function IsFusion5On()
  48.     return colours.test(redstone.getBundledInput(RedstoneIn), colours.lime)
  49. end
  50.  
  51. function MainFunc()
  52.     while true do
  53.         local w, h = Monitor.getSize()
  54.  
  55.         ClearMonitor()
  56.         GroupBoxHeader(2, 1, w - 2, "Fusion Info", colours.white, colours.black)
  57.    
  58.         if (IsFusion1On()) then DrawText(2, 3, "Fusion 1 ONLINE", colours.white, colours.green)
  59.         else DrawText(2, 3, "Fusion 1 OFFLINE", colours.white, colours.red) end
  60.    
  61.         if (IsFusion2On()) then DrawText(2, 5, "Fusion 2 ONLINE", colours.white, colours.green)
  62.         else DrawText(2, 5, "Fusion 2 OFFLINE", colours.white, colours.red) end
  63.    
  64.         if (IsFusion3On()) then DrawText(2, 7, "Fusion 3 ONLINE", colours.white, colours.green)
  65.         else DrawText(2, 7, "Fusion 3 OFFLINE", colours.white, colours.red) end
  66.    
  67.         if (IsFusion4On()) then DrawText(2, 9, "Fusion 4 ONLINE", colours.white, colours.green)
  68.         else DrawText(2, 9, "Fusion 4 OFFLINE", colours.white, colours.red) end
  69.  
  70.         if (IsFusion5On()) then DrawText(2, 11, "Fusion 5 ONLINE", colours.white, colours.green)
  71.         else DrawText(2, 11, "Fusion 5 OFFLINE", colours.white, colours.red) end
  72.  
  73.         os.sleep(1)
  74.     end
  75. end
  76.  
  77. MainFunc()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement