ZathegamE

requestbacktank.lua

Jun 17th, 2024 (edited)
734
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. 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. list_.close()
  8. function has(table,compare)
  9.     for _,b in pairs(table) do
  10.         if b == compare then
  11.             return true
  12.         end
  13.     end
  14.     return false
  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. term.clear()
  26. term.setCursorPos(1,1)
  27. term.write("Solliciter Recharge [o]/[n]")
  28. term.setCursorPos(1,2)
  29. open = false
  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.             if type == "name" then
  36.                 if has(list,data) then
  37.                   --  print(data)
  38.                     rs.setOutput("left",false)
  39.                     open = true
  40.                     term.clear()
  41.                     term.setCursorPos(1,1)
  42.                     term.write("Accès accordé")
  43.                                    eepy(28.13)
  44.                     rs.setOutput("left",true)
  45.                 end
  46.                 end
  47.             end
  48.             end
  49.             else
  50.             if input == "n" then
  51.             term.write("ok")
  52.             sleep(0.5)
  53.             else
  54.             term.write("accès refusé")
  55.             sleep(2)
  56.             end
  57.             end
  58.             end
  59.     if not open then
  60.         rs.setOutput("left",true)
  61. end
Advertisement
Add Comment
Please, Sign In to add comment