TeoremaPi

Directo 1 Mando

Nov 30th, 2020
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.07 KB | None | 0 0
  1. -- guardamos la pantalla del monitor
  2. m = term.current();               -- monitor
  3.  
  4. -- tamano de la pantalla
  5. wm, hm = m.getSize() -- ancho y alto maximos
  6.  
  7. -- limpiamos la pantalla
  8. m.setBackgroundColor(colors.black)
  9. m.clear()
  10.  
  11. -- conectamos el wifi
  12. rednet.open("back")
  13.  
  14. -- pintamos un cuadro
  15. paintutils.drawFilledBox(2, 2, wm-1, 5, colors.green)
  16.  
  17. -- variable para guardar si esta encendido
  18. encendido = true
  19.  
  20. while true do
  21.     -- esperamos a que alguien pulse la pantalla    
  22.     event, button, x, y = os.pullEvent( "mouse_click" )
  23.  
  24.     -- mandamos el mensaje y cambiamos el boton de color
  25.     if x>=2 and x<=wm-1 and y>=2 and y<=5 then
  26.        
  27.         -- limpiamos la pantalla
  28.         m.setBackgroundColor(colors.black)
  29.         m.clear()
  30.  
  31.         if encendido then
  32.             rednet.send(4,'on')
  33.             encendido = false
  34.             paintutils.drawFilledBox(2, 2, wm-1, 5, colors.red)
  35.         else
  36.             rednet.send(4,'off')
  37.             encendido = true
  38.             paintutils.drawFilledBox(2, 2, wm-1, 5, colors.green)
  39.         end
  40.     end
  41.  
  42. end
Add Comment
Please, Sign In to add comment