Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@xyzz
Created August 12, 2013 18:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xyzz/2e8458f5a1ac9f95ee88 to your computer and use it in GitHub Desktop.
Save xyzz/2e8458f5a1ac9f95ee88 to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
import sys
from toolset import read_int, read_short, read_byte
def main():
if len(sys.argv) != 3:
print("Usage: process-script.py script.txt output.txt")
return
with open(sys.argv[1], "rb") as fin:
count = read_short(fin)
#print("{} entries".format(count))
strings = []
for i in range(count):
kind = read_short(fin)
argv = read_byte(fin)
row = read_short(fin)
argcstr = [""] * argv
argcnum = [0] * argv
argcnum2 = [0] * argv
argcnum3 = [0] * argv
if kind == 8:
continue
for k in range(argv):
argcnum[k] = read_byte(fin)
if argcnum[k] in [0, 1]:
argcnum2[k] = read_short(fin)
elif argcnum[k] == 0x64:
argcnum2[k] = read_short(fin)
elif argcnum[k] == 0x65:
argcnum2[k] = fin.read(3)
elif argcnum[k] == 0xc8:
word0 = read_short(fin)
argcstr[k] = fin.read(word0).decode("utf-8")
strings.append(argcstr[k])
else:
pass
with open(sys.argv[2], "w") as fout:
fout.write("\n".join(strings))
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment