Advertisement
Rochet2

Untitled

Aug 10th, 2014
423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.17 KB | None | 0 0
  1.  
  2. -- Define what to find, remove the find table to find all
  3. local find = {}
  4. find.SpellSchoolMask = true
  5.  
  6. -- utility
  7. local function WriteFile(path, str)
  8.     local f = assert(io.open(path, "w"))
  9.     f:write(str)
  10.     f:close()
  11. end
  12. local function OpenFile(path)
  13.     local f = assert(io.open(path, "r"))
  14.     local str = f:read("*all")
  15.     f:close()
  16.     return str
  17. end
  18. local function scandir(path, files)
  19.     local f = io.popen('dir "'..path..'" /b')
  20.     if (not f) then return files end
  21.    
  22.     for name in f:lines() do
  23.         if (name:find("%.")) then
  24.             if (name:find("%.h$")) then
  25.                 table.insert(files, path.."/"..name)
  26.             end
  27.         else
  28.             scandir(path.."/"..name, files)
  29.         end
  30.     end
  31.     f:close()
  32.     return files
  33. end
  34.  
  35. -- Path to source
  36. local Files = scandir("E:/Cores/Eluna/trin_wotlk/source/src", {})
  37.  
  38. local enums = {}
  39. for k,v in ipairs(Files) do
  40.     for code, name in OpenFile(v):gmatch("(enum%s+([%w_]+)[%s\n]+%b{})") do
  41.         if (not find or find[name]) then
  42.             table.insert(enums, code)
  43.         end
  44.     end
  45. end
  46.  
  47. -- Output file path
  48. WriteFile("enumss.lua", table.concat(enums, "\n\n"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement