Guest User

request.lua

a guest
Jun 16th, 2024
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.45 KB | None | 0 0
  1. local integrator = peripheral.find("redstoneIntegrator")
  2. local envd = peripheral.find("environmentDetector")
  3. list_ = fs.open("allow_list.txt","r")
  4. list = textutils.unserialize(list_.readAll())
  5. list_.close()
  6. function has(table,compare)
  7.     for _,b in pairs(table) do
  8.         if b == compare then
  9.             return true
  10.         end
  11.     end
  12.     return false
  13. end  
  14. open = false
  15. while true do
  16.     open = false
  17.    term.clear()
  18.    term.setCursorPos(1,1)
  19.    term.write("request health : [y]/[n]")
  20.    term.setCursorPos(1,2)
  21.    input = read()
  22.    if input == "y" then
  23.      entities = envd.scanEntities(5) or {}
  24.     for _,tab in pairs(entities) do
  25.         for type,data in pairs(tab) do
  26.             if type == "name" then
  27.                 if has(list,data) then
  28.                   --  print(data)
  29.                     integrator.setOutput("bottom",false)
  30.                     open = true
  31.                     term.clear()
  32.                     term.setCursorPos(1,1)
  33.                     term.write("access granted")
  34.                     sleep(2)
  35.                     integrator.setOutput("bottom",true)
  36.                 end
  37.                 end
  38.             end
  39.             end
  40.             else
  41.             if input == "n" then
  42.             term.clear()
  43.             term.setCursorPos(1,1)
  44.             term.write("ok")
  45.             sleep(2)
  46.             end
  47.             end
  48.             end
  49.     if not open then
  50.         integrator.setOutput("bottom",true)
  51. end
Advertisement
Add Comment
Please, Sign In to add comment