Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local integrator = peripheral.find("redstoneIntegrator")
- local envd = peripheral.find("environmentDetector")
- local speaker = peripheral.find("speaker")
- rs.setOutput("left",true)
- list_ = fs.open("allow_list.txt","r")
- list = textutils.unserialize(list_.readAll())
- list_.close()
- function has(table,compare)
- for _,b in pairs(table) do
- if b == compare then
- return true
- end
- end
- return false
- end
- open = false
- function eepy(time)
- local timer_id = os.startTimer(time)
- local event, id
- repeat
- event, id = os.pullEvent("timer")
- until id == timer_id
- end
- while true do
- term.clear()
- term.setCursorPos(1,1)
- term.write("Solliciter Recharge [o]/[n]")
- term.setCursorPos(1,2)
- open = false
- input = read()
- if input == "o" then
- entities = envd.scanEntities(3) or {}
- for _,tab in pairs(entities) do
- for type,data in pairs(tab) do
- if type == "name" then
- if has(list,data) then
- -- print(data)
- rs.setOutput("left",false)
- open = true
- term.clear()
- term.setCursorPos(1,1)
- term.write("Accès accordé")
- eepy(28.13)
- rs.setOutput("left",true)
- end
- end
- end
- end
- else
- if input == "n" then
- term.write("ok")
- sleep(0.5)
- else
- term.write("accès refusé")
- sleep(2)
- end
- end
- end
- if not open then
- rs.setOutput("left",true)
- end
Advertisement
Add Comment
Please, Sign In to add comment