Advertisement
Guest User

Multi-touch.lua

a guest
Jul 12th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.72 KB | None | 0 0
  1. mon = peripheral.wrap("right")
  2. rednet.open("top")
  3.  
  4. --setup
  5.     mon.setTextScale(1)
  6.    
  7. --pre start
  8.     mon.setBackgroundColor(colors.black)
  9.     mon.clear()
  10.  
  11. function off_text(c,r)
  12.     mon.setCursorPos(c,r)
  13.     mon.setTextColor(colors.white)
  14.     mon.setBackgroundColor(colors.red)
  15.     mon.write("Off")
  16. end
  17. function on_text(c,r)
  18.     mon.setCursorPos(c,r)
  19.     mon.setTextColor(colors.white)
  20.     mon.setBackgroundColor(colors.lime)
  21.     mon.write("On ")
  22. end
  23.  
  24. -- Button 1
  25. while true do
  26.     off_text(2,2)
  27.     event, side, x, y = os.pullEvent("monitor_touch")
  28.         if x + 1 > 2 and x < 5 and y == 2 then
  29.             on_text(2,2)
  30.             if os.pullEvent("monitor_touch") then
  31.             end
  32.         end
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement