ZathegamE

request.lua

Jun 16th, 2024 (edited)
513
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.             return true
  19.         end
  20.     end
  21.     return false
  22. end  
  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.                 if has(list,data) then
  34.                   --  print(data)
  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.                     integrator.setOutput("bottom",true)
  42.                 end
  43.                 end
  44.             end
  45.             end
  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
Advertisement
Add Comment
Please, Sign In to add comment