Dojnaz

Light Switch

May 5th, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Monitor side ("front", "back", "left", "right", "top" or "bottom")
  2. local cmon = peripheral.wrap("top")
  3.  
  4. --Start on or off? (0=off, 1=on)
  5. local state = 0
  6. while true do
  7.     if state==1 then
  8. --Colour of the light ("white", "orange", "magenta", "lightBlue", "yellow", "lime", "pink", "gray", "lightGray", "cyan", "purple", "blue", "brown", "green", "red", "black")
  9.         cmon.setBackgroundColor(colors.white)
  10. -- Do not change anything below this line
  11.         cmon.clear()
  12.     else
  13.         cmon.setBackgroundColor(colors.black)
  14.         cmon.clear()
  15.     end
  16.     event, side, x,y = os.pullEvent()
  17.     if event == "monitor_touch" then
  18.         state = (state + 1) % 2
  19.     end
  20. end
Add Comment
Please, Sign In to add comment