Advertisement
Pirnogion

ControlPoint

Jan 15th, 2015
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --API's
  2. local cmpnt  = require("component")
  3. local event  = require("event")
  4. local colors = require("colors")
  5.  
  6. --Components
  7. local red   = cmpnt.redstone
  8. local graph = cmpnt.gpu
  9.  
  10. --Variables
  11. local running = true
  12. local width, height = graph.getResolution()
  13. local string = "/dev/null"
  14. local char = "*"
  15.  
  16. local password = {
  17. {1, 1, 1, 1},
  18. {1, 1, 1, 1},
  19. {1, 1, 1, 1},
  20. {1, 1, 1, 1}
  21. }
  22.  
  23. --Component proxy
  24. local MainMonitor = cmpnt.proxy(cmpnt.get("fec2a1ea"))
  25. local MMResolution = {}
  26. MMResolution["x"], MMResolution["y"] = graph.getResolution()
  27.  
  28. local DoorSection = {}
  29. DoorSection["RSIO"] = cmpnt.proxy(cmpnt.get("3a59ac5e"))
  30. DoorSection["Monitor"] = cmpnt.proxy(cmpnt.get("2578"))
  31.  
  32. --Init
  33. graph.fill(1, 1, width, height, " ")
  34.  
  35. --functions
  36. local function CheckPassword()
  37.   for i=1, 4, 1 do
  38.     for j=1, 4, 1 do
  39.       if ( (graph.get(j, i) == "*" and password[j][i] == 0) or (graph.get(j, i) == " " and password[j][i] == 1) ) then return false end
  40.     end
  41.   end
  42.  
  43.   return true
  44. end
  45.  
  46. --In
  47. graph.bind(DoorSection["Monitor"].address)
  48. graph.setResolution(50, 17)
  49. width, height = graph.getResolution()
  50.  
  51. local function clearmon()
  52.   graph.setForeground(0x000000)
  53.   graph.setBackground(0xffffff)
  54.   graph.fill(1, 1, width, height, " ")
  55.  
  56.   string = "ВВЕДИТЕ ПАРОЛЬ"
  57.   graph.set(width/2-#string/2, 2, string)
  58. end
  59.  
  60. clearmon()
  61.  
  62. while running do
  63.   local _, _, x, y, but = event.pull("touch")
  64.   if (but == 1) then
  65.     char = "*"
  66.   elseif (but == 2) then
  67.     graph.char = " "
  68.   end
  69.   graph.set(x, y, char)
  70.   if (x == 1 and y == 1) then
  71.     if (CheckPassword()) then
  72.       DoorSection["RSIO"].setOutput(3, 1)
  73.       os.sleep(2)
  74.       DoorSection["RSIO"].setOutput(3, 0)
  75.     end
  76.   clearmon()
  77.   end
  78. end
  79.  
  80. --Out
  81. graph.bind(MainMonitor.address)
  82. graph.setResolution(MMResolution["x"], MMResolution["y"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement