Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- guardamos la pantalla del monitor
- m = term.current(); -- monitor
- -- tamano de la pantalla
- wm, hm = m.getSize() -- ancho y alto maximos
- -- limpiamos la pantalla
- m.setBackgroundColor(colors.black)
- m.clear()
- -- conectamos el wifi
- rednet.open("back")
- -- pintamos un cuadro
- paintutils.drawFilledBox(2, 2, wm-1, 5, colors.green)
- -- variable para guardar si esta encendido
- encendido = true
- while true do
- -- esperamos a que alguien pulse la pantalla
- event, button, x, y = os.pullEvent( "mouse_click" )
- -- mandamos el mensaje y cambiamos el boton de color
- if x>=2 and x<=wm-1 and y>=2 and y<=5 then
- -- limpiamos la pantalla
- m.setBackgroundColor(colors.black)
- m.clear()
- if encendido then
- rednet.send(4,'on')
- encendido = false
- paintutils.drawFilledBox(2, 2, wm-1, 5, colors.red)
- else
- rednet.send(4,'off')
- encendido = true
- paintutils.drawFilledBox(2, 2, wm-1, 5, colors.green)
- end
- end
- end
Add Comment
Please, Sign In to add comment