Just had a quick look at the code, the syntax should be
but the program has several flaws, it doesn't change the level numbers (so the output will not be correct), for the input it doesn't check for empty lines, so it will try to open a file it can't at the end of file if it is, as in most text files, in it's own line, and crash (just insert something like if pair[0]=="": continue in line 15 to avoid it), and it opens all input files multiple times for no apparent reason...
This should work properly:
(in Lua)
and you can specify multiple levels per set per line and use arbitrary white space as separator.
Code:
file[tab]number
but the program has several flaws, it doesn't change the level numbers (so the output will not be correct), for the input it doesn't check for empty lines, so it will try to open a file it can't at the end of file if it is, as in most text files, in it's own line, and crash (just insert something like if pair[0]=="": continue in line 15 to avoid it), and it opens all input files multiple times for no apparent reason...
This should work properly:
(in Lua)
Code:
function levels(s)
local function g(i) return s:byte(i)+s:byte(i+1)*256 end
local n, p, t = g(5), 7, {}
for i=1, n do
local a = g(p)
table.insert(t,s:sub(p+4, p+a+1))
p = p+a+2
end
return t
end
if #arg~=2 then
io.stderr:write("Usage: "..arg[0].." input output")
os.exit(1)
end
local inp = assert(io.open(arg[1], "r"))
local dat = inp:read("*a")
inp:close()
local a = {}
for line in dat:gmatch("[^\r\n]+") do
local t = {}
for w in line:gmatch("%S+") do table.insert(t,w) end
local inp = assert(io.open(table.remove(t,1), "rb"))
local ls = levels(inp:read("*a"))
inp:close()
for _,x in ipairs(t) do table.insert(a,ls[tonumber(x)]) end
end
function b(n) return string.char(n%256,math.floor(n/256)) end
local out = assert(io.open(arg[2], "wb"))
out:write("\xac\xaa\x02\x00"..b(#a))
for i,x in ipairs(a) do out:write(b(#x+2)..b(i)..x) end
out:close()
and you can specify multiple levels per set per line and use arbitrary white space as separator.
Code:
CCLP1.dat 123 2
JoshL5.dat 9