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)
|
| 3 | + | local speaker = peripheral.find("speaker")
|
| 4 | rs.setOutput("left",true)
| |
| 5 | list_ = fs.open("allow_list.txt","r")
| |
| 6 | list = textutils.unserialize(list_.readAll()) | |
| 7 | - | function eepy(t) |
| 7 | + | |
| 8 | - | local timer_id = os.startTimer(t) |
| 8 | + | |
| 9 | - | local event, id |
| 9 | + | |
| 10 | - | repeat |
| 10 | + | |
| 11 | - | event, id = os.pullEvent("timer")
|
| 11 | + | |
| 12 | - | until id == timer_id |
| 12 | + | |
| 13 | end | |
| 14 | - | |
| 14 | + | |
| 15 | end | |
| 16 | open = false | |
| 17 | function eepy(time) | |
| 18 | local timer_id = os.startTimer(time) | |
| 19 | local event, id | |
| 20 | repeat | |
| 21 | event, id = os.pullEvent("timer")
| |
| 22 | until id == timer_id | |
| 23 | end | |
| 24 | while true do | |
| 25 | - | open = false |
| 25 | + | term.clear() |
| 26 | - | term.clear() |
| 26 | + | term.setCursorPos(1,1) |
| 27 | - | input = rs.getInput("back")
|
| 27 | + | term.write("Solliciter Recharge [o]/[n]")
|
| 28 | - | if input == true then |
| 28 | + | term.setCursorPos(1,2) |
| 29 | - | entities = envd.scanEntities(5) or {}
|
| 29 | + | |
| 30 | input = read() | |
| 31 | if input == "o" then | |
| 32 | entities = envd.scanEntities(3) or {}
| |
| 33 | for _,tab in pairs(entities) do | |
| 34 | for type,data in pairs(tab) do | |
| 35 | - | integrator.setOutput("bottom",false)
|
| 35 | + | |
| 36 | if has(list,data) then | |
| 37 | -- print(data) | |
| 38 | rs.setOutput("left",false)
| |
| 39 | - | os.queueEvent("Accès", "accordé")
|
| 39 | + | |
| 40 | - | eepy(2) |
| 40 | + | |
| 41 | - | integrator.setOutput("bottom",true)
|
| 41 | + | |
| 42 | term.write("Accès accordé")
| |
| 43 | eepy(28.13) | |
| 44 | rs.setOutput("left",true)
| |
| 45 | end | |
| 46 | end | |
| 47 | - | if input == false then |
| 47 | + | |
| 48 | - | eepy(0.05) |
| 48 | + | |
| 49 | else | |
| 50 | - | os.queueEvent("Accès", "refusé")
|
| 50 | + | if input == "n" then |
| 51 | - | eepy(2) |
| 51 | + | term.write("ok")
|
| 52 | sleep(0.5) | |
| 53 | else | |
| 54 | term.write("accès refusé")
| |
| 55 | sleep(2) | |
| 56 | - | integrator.setOutput("bottom",true)
|
| 56 | + | |
| 57 | end | |
| 58 | end | |
| 59 | if not open then | |
| 60 | rs.setOutput("left",true)
| |
| 61 | end |