Advertisement
Dojnaz

CC Oxygen Monitor

Nov 17th, 2020 (edited)
767
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.83 KB | None | 0 0
  1. local title        = "Spawn Oxygen"
  2. local monitorSide  = "right"
  3. local redstoneSide = "left"
  4.  
  5. function pullRedstone()
  6.   os.pullEvent("redstone")
  7. end
  8.  
  9. function sleepASec()
  10.   sleep(1)
  11. end
  12.  
  13. while (true) do
  14.   mon = peripheral.wrap(monitorSide)
  15.   mon.clear()
  16.   sizeX,sizeY = mon.getSize()
  17.   titlePos = math.floor(sizeX/2) - math.floor(#title / 2)
  18.   if (titlePos < 1) then
  19.     titlePos = 1
  20.   end
  21.   if (redstone.getInput(redstoneSide)) then
  22.     oxyStatus = colors.lightBlue
  23.   else
  24.     oxyStatus = colors.red
  25.   end
  26.  
  27.   mon.setCursorPos(titlePos+1,1)
  28.   mon.write(title)
  29.  
  30.   mon.setBackgroundColor(oxyStatus)
  31.   for x = 2, sizeX - 1, 1 do
  32.     for y = 3, sizeY - 1, 1 do
  33.       mon.setCursorPos(x,y)
  34.       mon.write(" ")
  35.     end
  36.   end
  37.   mon.setBackgroundColor(colors.black)
  38.  
  39.   parallel.waitForAny(sleepASec, pullRedstone)
  40. end
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement