ardittristan

Buttons

Jan 3rd, 2015
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.41 KB | None | 0 0
  1. mouseWidth = 0
  2. mouseHeight = 0
  3. -- change the ("top") to ("[the side where the monitor is]")
  4. monitor = peripheral.wrap("top")
  5. monitor.clear()
  6. monitor.setCursorPos(1,1)
  7. monitor.setBackgroundColour((colours.lime))
  8.  
  9. -- first add monitor.setCursorPos(1,[number 2 higer than the last one])
  10. -- then add monitor.write("[text 7 long]")
  11.  
  12. monitor.setCursorPos(1,1)
  13. monitor.write(" blaze ")
  14.  
  15. monitor.setCursorPos(1,3)
  16. monitor.write(" ender ")
  17.  
  18. monitor.setCursorPos(1,5)
  19. monitor.write("  uit  ")
  20.  
  21. monitor.setBackgroundColour((colours.black))
  22.  
  23. -- first add if mouseWidth > 0 and mouseWidth < 12 and mouseHeight == [same nuber as above (second number)] then
  24. --             rs.setOutput("[side]",true)
  25. --           end
  26. -- then add to the one with the mouseHeight of 5 rs.setOutput("[side you used]",false)
  27.  
  28. function checkClickPosition()
  29.   if mouseWidth > 0 and mouseWidth < 12 and mouseHeight == 1 then
  30.     rs.setOutput("left",true)
  31.   end
  32.  
  33.   if mouseWidth > 0 and mouseWidth < 12 and mouseHeight == 3 then
  34.     rs.setOutput("back",true)
  35.   end
  36.  
  37.   if mouseWidth > 0 and mouseWidth < 12 and mouseHeight == 5 then
  38.     rs.setOutput("left",false)
  39.     rs.setOutput("back",false)
  40.   end
  41. end
  42.  
  43. -- nothing to add/change here
  44.  
  45. repeat
  46.  
  47.   event,p1,p2,p3 = os.pullEvent()
  48.  
  49.    if event=="monitor_touch" then
  50.  
  51.      mouseWidth = p2
  52.      mouseHeight = p3
  53.      checkClickPosition()
  54.  
  55.    end
  56.  
  57.  
  58.  
  59. until event=="char"and p1==("x")
Advertisement
Add Comment
Please, Sign In to add comment