View difference between Paste ID: xbmxVuDw and ARtrU85n
SHOW: | | - or go back to the newest paste.
1-
--API's
1+
--API's
2-
local cmpnt  = require("component")
2+
local cmpnt  = require("component")
3-
local event  = require("event")
3+
local event  = require("event")
4-
local colors = require("colors")
4+
local colors = require("colors")
5-
5+
6-
--Components
6+
--Components
7-
local red   = cmpnt.redstone
7+
local red   = cmpnt.redstone
8-
local graph = cmpnt.gpu
8+
local graph = cmpnt.gpu
9-
9+
10-
--Variables
10+
--Variables
11-
local running = true
11+
local running = true
12-
local width, height = graph.getResolution()
12+
local width, height = graph.getResolution()
13-
local string = "/dev/null"
13+
local string = "/dev/null"
14-
local char = "*"
14+
local char = "*"
15-
15+
16-
local password = {
16+
local password = {
17-
{1, 1, 1, 1},
17+
{1, 1, 1, 1},
18-
{1, 1, 1, 1},
18+
{1, 1, 1, 1},
19-
{1, 1, 1, 1},
19+
{1, 1, 1, 1},
20-
{1, 1, 1, 1}
20+
{1, 1, 1, 1}
21-
}
21+
}
22-
22+
23-
--Component proxy
23+
--Component proxy
24-
local MainMonitor = cmpnt.proxy(cmpnt.get("fec2a1ea"))
24+
local MainMonitor = cmpnt.proxy(cmpnt.get("fec2a1ea"))
25-
local MMResolution = {}
25+
local MMResolution = {}
26-
MMResolution["x"], MMResolution["y"] = graph.getResolution()
26+
MMResolution["x"], MMResolution["y"] = graph.getResolution()
27-
27+
28-
local DoorSection = {}
28+
local DoorSection = {}
29-
DoorSection["RSIO"] = cmpnt.proxy(cmpnt.get("3a59ac5e"))
29+
DoorSection["RSIO"] = cmpnt.proxy(cmpnt.get("3a59ac5e"))
30-
DoorSection["Monitor"] = cmpnt.proxy(cmpnt.get("2578"))
30+
DoorSection["Monitor"] = cmpnt.proxy(cmpnt.get("2578"))
31-
31+
32-
--Init
32+
--Init
33-
graph.fill(1, 1, width, height, " ")
33+
graph.fill(1, 1, width, height, " ")
34-
34+
35-
--functions
35+
--functions
36-
local function CheckPassword()
36+
local function CheckPassword()
37-
  for i=1, 4, 1 do
37+
  for i=1, 4, 1 do
38-
    for j=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 
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
40+
    end
41-
  end
41+
  end
42-
42+
43-
  return true
43+
  return true
44-
end
44+
end
45-
45+
46-
--In
46+
--In
47-
graph.bind(DoorSection["Monitor"].address)
47+
graph.bind(DoorSection["Monitor"].address)
48-
graph.setResolution(50, 17)
48+
graph.setResolution(50, 17)
49-
width, height = graph.getResolution()
49+
width, height = graph.getResolution()
50-
50+
51-
local function clearmon()
51+
local function clearmon()
52-
  graph.setForeground(0x000000)
52+
  graph.setForeground(0x000000)
53-
  graph.setBackground(0xffffff)
53+
  graph.setBackground(0xffffff)
54-
  graph.fill(1, 1, width, height, " ")
54+
  graph.fill(1, 1, width, height, " ")
55-
  
55+
  
56-
  string = "ВВЕДИТЕ ПАРОЛЬ"
56+
  string = "ВВЕДИТЕ ПАРОЛЬ"
57-
  graph.set(width/2-#string/2, 2, string)
57+
  graph.set(width/2-#string/2, 2, string)
58-
end
58+
end
59-
59+
60-
clearmon()
60+
clearmon()
61-
61+
62-
while running do
62+
while running do
63-
  local _, _, x, y, but = event.pull("touch")
63+
  local _, _, x, y, but = event.pull("touch")
64-
  if (but == 1) then
64+
  if (but == 1) then
65-
    char = "*"
65+
    char = "*"
66-
  elseif (but == 2) then
66+
  elseif (but == 2) then
67-
    graph.char = " "
67+
    graph.char = " "
68-
  end
68+
  end
69-
  graph.set(x, y, char)
69+
  graph.set(x, y, char)
70-
  if (x == 1 and y == 1) then
70+
  if (x == 1 and y == 1) then
71-
    if (CheckPassword()) then
71+
    if (CheckPassword()) then
72-
      DoorSection["RSIO"].setOutput(3, 1)
72+
      DoorSection["RSIO"].setOutput(3, 1)
73-
      os.sleep(2)
73+
      os.sleep(2)
74-
      DoorSection["RSIO"].setOutput(3, 0)
74+
      DoorSection["RSIO"].setOutput(3, 0)
75-
    end
75+
    end
76-
  clearmon()
76+
  clearmon()
77-
  end
77+
  end
78-
end
78+
end
79-
79+
80-
--Out
80+
--Out
81-
graph.bind(MainMonitor.address)
81+
graph.bind(MainMonitor.address)
82
graph.setResolution(MMResolution["x"], MMResolution["y"])