Advertisement
ChanServ

index.txt parser

Nov 17th, 2019
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.15 KB | None | 0 0
  1. local dat = [[...]]
  2.  
  3. local a = {}
  4. local i = 0
  5. for s in string.gmatch(dat, "pastebin.com/(%w+)") do
  6.     i = i+1
  7.     a[i] = {
  8.         url = "https://pastebin.com/raw/"..s
  9.     }
  10. end
  11. i = 0
  12. for s in string.gmatch(dat, " %- ([%w %p_]+)\n") do
  13.     i = i+1
  14.     a[i].filename = s
  15. end
  16. for k, v in ipairs(a) do
  17.     local ver = string.match(v.filename, "shitcheat_(%d.%d%l?).lua")
  18.     if ver then
  19.         a[k].version = ver
  20.         a[k].changelog = string.match(dat, "shitcheat_%d.%d%l?_to_"..ver.."_changelog.txt")
  21.     end
  22. end
  23.  
  24. print("local data = {")
  25. for k, v in ipairs(a) do
  26.     print("\t{")
  27.     local hidden = v.filename:find("_changelog.txt$") and true
  28.     if v.version then
  29.         print('\t\tname = "Shitcheat",')
  30.     elseif not hidden then
  31.         print('\t\tname = "CHANGEME",')
  32.     end
  33.     print(string.format('\t\tfilename = "%s",', v.filename))
  34.     print(string.format('\t\turl = "%s",', v.url))
  35.     if v.version then
  36.         print(string.format('\t\tversion = "%s",', v.version))
  37.     end
  38.     if v.changelog then
  39.         print(string.format('\t\tchangelog = "%s",', v.changelog))
  40.     end
  41.     if v.filename:find(".lua$") then
  42.         print("\t\texecutable = true,")
  43.     end
  44.     if hidden then
  45.         print("\t\thidden = true,")
  46.     end
  47.     print("\t},")
  48. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement