Advertisement
DustinRosebery

switch

Nov 25th, 2016
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. m = peripheral.wrap("top")
  2. mod = peripheral.wrap("left")
  3.  
  4. isOn = false
  5.  
  6. local function drawGreen()
  7. for i = 0, 20 do
  8. for j = 0, 20 do
  9. m.setBackgroundColor(colors.lime)
  10. m.setCursorPos(i,j)
  11. m.write(" ")
  12. end
  13.  
  14. local function drawRed()
  15. for i = 0, 20 do
  16. for j = 0, 20 do
  17. m.setBackgroundColor(colors.red)
  18. m.setCursorPos(i,j)
  19. m.write(" ")
  20. end
  21.  
  22. local function touch()
  23. local event side, xpos, ypos = os.pullEvent("monitor_touch")
  24.  
  25. if isOn then
  26. drawRed()
  27. rednet.open("left")
  28. rednet.broadcast("off")
  29. rednet.close("left")
  30. else
  31. drawGreen()
  32. rednet.open("left")
  33. rednet.broadcast("on")
  34. rednet.close("left")
  35. end
  36. end
  37.  
  38. while true do
  39.  
  40. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement