Advertisement
Guest User

ss

a guest
Feb 8th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. mouseWidth = 0
  2. mouseHeight = 0
  3. monitor = peripheral.wrap("top")
  4. monitor.clear()
  5. monitor.setCursorPos(1,1)
  6. w,h=monitor.getSize()
  7. print(w)
  8. print(h)
  9. monitor.setBackgroundColour((colours.lime))
  10. monitor.setCursorPos(2,2)
  11. monitor.write(" ON  ")
  12. monitor.setCursorPos(2,4)
  13. monitor.write(" OFF ")
  14. monitor.setBackgroundColour((colours.black))
  15. function checkClickPosition()
  16.   if mouseWidth > 1 and mouseWidth < 8 and mouseHeight == 2 then
  17.     -- button one clicked
  18.     rs.setOutput("right",true)
  19.     -- turns redstone connected to the right on
  20.   elseif mouseWidth > 1 and mouseWidth < 8 and mouseHeight == 4 then
  21.     -- button two clicked
  22.     rs.setOutput("right",false)
  23.     -- turns redstone connected to the left off
  24.   end -- ends the if loop
  25. end -- ends the function
  26. repeat
  27. event,p1,p2,p3 = os.pullEvent()
  28.  
  29.  
  30.    if event=="monitor_touch" then
  31.     mouseWidth = p2 -- sets mouseWidth
  32.      mouseHeight = p3 -- and mouseHeight
  33.      checkClickPosition() -- this runs our function
  34.      
  35.    end
  36. until event=="char" and p1==("x")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement