Programist135

Functions scanner

Oct 26th, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.52 KB | None | 0 0
  1. local filesystem = require("filesystem")
  2. local component = require("component")
  3. local string = require("string")
  4. local gpu = component.gpu
  5.  
  6. local resX = gpu.getResolution()
  7. local functions = 0
  8. local functionsFinded = {}
  9. local number = math.random(1, 10000000000)
  10.  
  11. if not filesystem.exists("/functionsScanner/") then
  12.     filesystem.makeDirectory("/functionsScanner/")
  13. else
  14.     file = io.open("/functionsScanner/" .. number .. ".txt", "w")
  15. end
  16.  
  17. io.write("Путь к библиотеке: ")
  18. local lib = io.read()
  19.  
  20. if not filesystem.exists(lib) then
  21.     io.stderr:write("Файла " .. lib .. " не существует!\n")
  22.     return
  23. end
  24.  
  25. print("Выполняется полное сканирование библиотеки...")
  26. for line in io.lines(lib) do
  27.     if string.sub(line, 1, 8) == "function" then
  28.         table.insert(functionsFinded, string.sub(line, 10, resX))
  29.         functions = functions+1
  30.     end
  31. end
  32.  
  33. if functions < 1 then
  34.     io.stderr:write("Ни одна функция не была найдена.")
  35. elseif functions > 0 then
  36.     print("Сканирование завершено.")
  37.     print("Сохранение...")
  38.     file:write("Programist135 library functions scanner\n")
  39.     file:write("--------------------------------------------\n")
  40.     file:write("Найденные функции (" .. functions .. "): \n")
  41.     for _, findedFunction in pairs(functionsFinded) do
  42.         file:write(findedFunction .. "\n")
  43.     end
  44.     file:flush()
  45.     file:close()
  46.     print("Файл сохранен как /functionsScanner/" .. number .. ".txt")
  47. end
Advertisement
Add Comment
Please, Sign In to add comment