Advertisement
mickaelxd

monitor avisa reator

May 20th, 2024 (edited)
738
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.05 KB | None | 0 0
  1. local monitor = peripheral.wrap("top") -- Configura o monitor na parte de cima
  2. monitor.setTextScale(1) -- Define o tamanho do texto como 1
  3.  
  4. function updateMonitor(status)
  5.     monitor.clear()
  6.     local width, height = monitor.getSize()
  7.  
  8.     local line1 = "REATOR"
  9.     local line2 = status and "ATIVO" or "DESLIGADO"
  10.  
  11.     monitor.setBackgroundColor(status and colors.green or colors.red)
  12.     monitor.setTextColor(colors.white)
  13.     monitor.clear()
  14.  
  15.     -- Centralizar a primeira linha
  16.     local x1 = math.floor((width - #line1) / 2) + 1
  17.     local y1 = math.floor(height / 2) - 1
  18.     monitor.setCursorPos(x1, y1)
  19.     monitor.write(line1)
  20.  
  21.     -- Centralizar a segunda linha
  22.     local x2 = math.floor((width - #line2) / 2) + 1
  23.     local y2 = math.floor(height / 2) + 1
  24.     monitor.setCursorPos(x2, y2)
  25.     monitor.write(line2)
  26. end
  27.  
  28. -- Loop principal
  29. while true do
  30.     local signal = redstone.getInput("back") -- Altere "back" para a direção correta
  31.     updateMonitor(signal)
  32.     sleep(1) -- Aguarda 1 segundo antes de verificar novamente
  33. end
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement