Advertisement
Guest User

compc

a guest
Mar 27th, 2015
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.65 KB | None | 0 0
  1. local t = {...}
  2. local file = fs.open(t[1],"r")
  3. local cont = file.readAll()
  4. file.close()
  5. local function compile(c)
  6.  
  7. local cont2 = string.dump(c)
  8. local i = string.len(cont2)
  9. local n = 1
  10. local m = ""
  11. while (i > 0) do
  12. byt = tostring(string.byte(cont2,n) + math.abs(math.floor(200*math.sin(n))))
  13. while (string.len(byt) < 3) do
  14. byt = "0".. byt
  15. end
  16. m = m .. "a" .. byt
  17. i = i -1
  18. n = n + 1
  19. end
  20. return m
  21. end
  22.  
  23. local function compileN(c)
  24.  
  25. local cont2 = string.dump(c)
  26. local i = string.len(cont2)
  27. local n = 1
  28. local m = ""
  29. while (i > 0) do
  30. byt = tostring(string.byte(cont2,n))
  31. while (string.len(byt) < 3) do
  32. byt = "0".. byt
  33. end
  34. m = m .. "\\" .. byt
  35. i = i -1
  36. n = n + 1
  37. end
  38. return m
  39. end
  40.  
  41. function compileR(c,...)
  42.  
  43.  local function split(str, pat)
  44.    local t = {}  -- NOTE: use {n = 0} in Lua-5.0
  45.    local fpat = "(.-)" .. pat
  46.    local last_end = 1
  47.    local s, e, cap = str:find(fpat, 1)
  48.    while s do
  49.       if s ~= 1 or cap ~= "" then
  50.          table.insert(t,cap)
  51.       end
  52.       last_end = e+1
  53.       s, e, cap = str:find(fpat, last_end)
  54.    end
  55.    if last_end <= #str then
  56.       cap = str:sub(last_end)
  57.       table.insert(t, cap)
  58.    end
  59.    return t
  60. end
  61.  
  62. c = split(c,"a")
  63. local i = #c
  64. local n = 1
  65. local m = ""
  66. while (i > 0) do
  67. byt = tostring(tonumber(c[n]) - math.abs(math.floor(200*math.sin(n))))
  68. while (string.len(byt) < 3) do
  69. byt = "0".. byt
  70. end
  71. m = m .. "\\" .. byt
  72. i = i -1
  73. n = n + 1
  74. end
  75. return loadstring('loadstring("' .. m .. '")(...)')(...)
  76. end
  77.  
  78.  
  79. ir = compile(loadstring(cont))
  80. ir2 = compileN(compileR)
  81. local file2 = fs.open(t[2],"w")
  82. file2.writeLine('loadstring("' .. ir2 .. '")("' .. ir .. '",...)')
  83. file2.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement