Advertisement
Quintuple_agent

All monitor draw

Jan 18th, 2015
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.25 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 then
  15.                 if mouseHeight == 2 then
  16.                         rs.setOutput("bottom",true)
  17.                 elseif mouseHeight == 4 then
  18.                         rs.setOutput("bottom",false)
  19.                 end
  20.         end
  21. end
  22.  
  23. local function monitorDraw(monitor)
  24.         monitor.clear()
  25.         monitor.setCursorPos(1,1)
  26.         local w,h=monitor.getSize()
  27.         monitor.setBackgroundColour((colours.lime))
  28.         monitor.setCursorPos(2,2)
  29.         monitor.write("CLOSE")
  30.         monitor.setCursorPos(2,4)
  31.         monitor.write("OPEN ")
  32.         monitor.setBackgroundColour((colours.black))
  33. end
  34.  
  35. --Body
  36.  
  37. rs.setOutput("bottom", true)
  38.  
  39. monitorFind()
  40.  
  41. for index,mon in pairs(monitors) do
  42.     monitorDraw(mon)
  43. end
  44.  
  45. repeat
  46.         event,p1,p2,p3 = os.pullEvent()
  47.         if event=="monitor_touch" then
  48.                 checkClickPosition(p2,p3)
  49.         end
  50. until event=="char" and p1==("x")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement