Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -------------------
- -- encodeSTA.lua --
- -------------------
- -- For some game, I don't even know what it is lol.
- -- Run this within a folder with some TXT files in it.
- -- STA file conversions will be created in a "newSTA" subfolder.
- -- Pre-existing STA files will be replaced without prompting.
- require "lfs"
- require "bit"
- lfs.mkdir("newSTA")
- local header = string.char(0x00, 0x41, 0x54, 0x53, 0x20, 0x12, 0x03, 0x13)
- local function makeLong(long)
- return string.char(bit.rshift(bit.band(long, 0xFF000000), 24), bit.rshift(bit.band(long, 0xFF0000), 16), bit.rshift(bit.band(long, 0xFF00), 8), bit.band(long, 0xFF))
- end
- for entry in lfs.dir(lfs.currentdir()) do if entry:sub(-4):lower() == ".txt" then
- local lines, curLine = {[0] = {}}, 0
- local input = io.open(entry, "r")
- local output = io.open("newSTA/" .. entry:sub(1, #entry - 3) .. "sta", "wb")
- output:write(header)
- for line in io.lines(entry) do
- if line:sub(1, 24) == "*Do*Not*Edit*This*Line* " then
- curLine = curLine + 1
- lines[curLine] = {}
- else
- lines[curLine][#lines[curLine] + 1] = line
- end
- end
- output:write(makeLong(#lines))
- output:write("\00\00\00\00")
- for i = 1, #lines do
- local line = table.concat(lines[i], "\n")
- output:write(makeLong(#line))
- output:write(line)
- end
- input:close()
- output:close()
- end end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement