Advertisement
graywolf69

Buttons not working

Jan 18th, 2015
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.23 KB | None | 0 0
  1. local devices=peripheral.getNames()
  2. local monitors={}
  3.  
  4. local function monitorFind()
  5.  
  6. monitors={}
  7. for _,side in pairs(devices) do
  8.     if peripheral.getType(side)=="monitor" then table.insert(monitors,peripheral.wrap(side)) end
  9. end
  10.  
  11. end
  12.  
  13. local function checkClickPosition(mouseWidth,mouseHeight)
  14.         if mouseWidth >= 1 and mouseWidth <= 8 and mouseHeight == 2 then
  15.                         rs.setOutput("bottom",true)
  16.     elseif mouseWidth >= 1 and mouseWidth <= 8 and mouseHight == 4 then
  17.                         rs.setOutput("bottom",false)
  18.         end
  19. end
  20.  
  21. local function monitorDraw(monitor)
  22.         monitor.clear()
  23.         monitor.setCursorPos(1,1)
  24.         local w,h=monitor.getSize()
  25.         monitor.setBackgroundColour((colours.lime))
  26.         monitor.setCursorPos(2,2)
  27.         monitor.write("CLOSE")
  28.         monitor.setCursorPos(2,4)
  29.         monitor.write("OPEN ")
  30.         monitor.setBackgroundColour((colours.black))
  31. end
  32.  
  33. --Body
  34.  
  35. rs.setOutput("bottom", true)
  36.  
  37. monitorFind()
  38.  
  39. for index,mon in pairs(monitors) do
  40.     monitorDraw(mon)
  41. end
  42.  
  43. repeat
  44.         event,p1,p2,p3 = os.pullEvent()
  45.         if event=="monitor_touch" then
  46.                 checkClickPosition(p2,p3)
  47.         end
  48. until event=="char" and p1==("x")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement