Advertisement
colhaydutu

lockv4-2

Sep 7th, 2023 (edited)
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. modemSide = "back"
  2. targetID = 4190
  3. local monitor = peripheral.wrap("front")
  4.  
  5. local function drawBar()
  6. local w, h = monitor.getSize()
  7. term.redirect(monitor)
  8.  
  9. monitor.setBackgroundColor(colors.blue)
  10. monitor.clear()
  11. monitor.setTextColor(colors.white)
  12. paintutils.drawLine(2, 2, 3, 2, colors.red)
  13. monitor.setBackgroundColor(colors.blue)
  14. monitor.setCursorPos(5, 2)
  15. monitor.write("[Door Control]")
  16. paintutils.drawLine(22, 3, 22, 5, colors.red)
  17.  
  18.  
  19.  
  20. monitor.setCursorPos(3, 4)
  21. monitor.setBackgroundColor(colors.green)
  22. monitor.write("[Open]")
  23.  
  24. monitor.setCursorPos(10, 4)
  25. monitor.setBackgroundColor(colors.red)
  26. monitor.write("[Close]")
  27.  
  28.  
  29.  
  30.  
  31. end
  32.  
  33.  
  34. drawBar()
  35.  
  36. while true do
  37. local event, side, x, y = os.pullEvent("monitor_touch")
  38. monitor.setBackgroundColor(colors.gray)
  39.  
  40. if x >= 3 and x <= 7 and y == 4 then
  41. rednet.open(modemSide)
  42. rednet.send(targetID, "open")
  43. rednet.close(modemSide)
  44. elseif x >= 10 and x <= 17 and y == 4 then
  45. rednet.open(modemSide)
  46. rednet.send(targetID, "close")
  47. rednet.close(modemSide)
  48. end
  49.  
  50. drawBar()
  51.  
  52. os.sleep(1)
  53.  
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement