View difference between Paste ID: jG93Hdx3 and 7HqWsbN4
SHOW: | | - or go back to the newest paste.
1
local integrator = peripheral.find("redstoneIntegrator")
2
local envd = peripheral.find("environmentDetector")
3
integrator.setOutput("bottom",true)
4
list_ = fs.open("allow_list.txt","r")
5
list = textutils.unserialize(list_.readAll())
6
list_.close()
7
function eepy(t)
8
    local timer_id = os.startTimer(t)
9
    local event, id
10
        repeat
11
        event, id = os.pullEvent("timer")
12
        until id == timer_id
13
end
14
15
function has(table,compare)
16
    for _,b in pairs(table) do
17
        if b == compare then
18-
   term.setCursorPos(1,1)
18+
19-
   term.write("request health : [y]/[n]")
19+
20-
   term.setCursorPos(1,2)
20+
21-
   input = read()
21+
22-
   if input == "y" then
22+
23
open = false
24
while true do
25
    open = false
26
   term.clear()
27
   input = rs.getInput("back")
28
   if input == true then
29
     entities = envd.scanEntities(5) or {} 
30
    for _,tab in pairs(entities) do
31
        for type,data in pairs(tab) do
32
            if type == "name" then
33-
                    term.write("access granted")
33+
34-
                    sleep(2)
34+
35
                    integrator.setOutput("bottom",false)
36
                    open = true
37
                    term.clear()
38
                    term.setCursorPos(1,1)
39
                    os.queueEvent("Accès", "accordé")
40
                    eepy(2)
41-
            if input == "n" then
41+
42-
            term.clear()
42+
43-
            term.setCursorPos(1,1)
43+
44-
            term.write("ok")
44+
45-
            sleep(2)
45+
46
            else
47
            if input == false then
48
            eepy(0.05)
49
            else
50
            os.queueEvent("Accès", "refusé")
51
            eepy(2)
52
            end
53
            end
54
            end
55
    if not open then
56
        integrator.setOutput("bottom",true)
57
end