Advertisement
Guest User

startup

a guest
Sep 1st, 2014
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.90 KB | None | 0 0
  1. mouseWidth = 0
  2. mouseHeight = 0
  3.  
  4. monitor = peripheral.wrap("left")
  5. monitor.clear()
  6.  
  7. monitor.setCursorPos(1,1)
  8.  
  9. w,h=monitor.getSize()
  10.  
  11. print(w)
  12. print(h)
  13. term.setCursorPos(5,5)
  14. print("By mati9956")
  15. monitor.setBackgroundColour((colours.lime))
  16.  
  17. monitor.setCursorPos(2,2)
  18.  
  19. monitor.write(" ON  ")
  20.  
  21. monitor.setBackgroundColour((colours.red))
  22. monitor.setCursorPos(2,4)
  23.  
  24. monitor.write(" OFF ")
  25.  
  26. monitor.setBackgroundColour((colours.black))
  27.  
  28. function checkClickPosition()
  29.   if mouseWidth > 1 and mouseWidth < 8 and mouseHeight == 2 then
  30.     rs.setOutput("top",true)
  31.   elseif mouseWidth > 1 and mouseWidth < 8 and mouseHeight == 4 then
  32.     rs.setOutput("top",false)
  33.   end
  34. end
  35.    
  36. repeat
  37.  
  38.   event,p1,p2,p3 = os.pullEvent()
  39.  
  40.  
  41.    if event=="monitor_touch" then
  42.      mouseWidth = p2  
  43.      mouseHeight = p3  
  44.      checkClickPosition()
  45.      
  46.    end
  47.    
  48. until event=="char" and p1==("x")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement