Created
May 8, 2021 17:02
-
-
Save Xzonn/49ec0923eaccaf9eb17ba82c8e157939 to your computer and use it in GitHub Desktop.
This script can be used to extract text content from <World's End Club>.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script can be used to extract text content from <World's End Club>. | |
# You should firstly extract ".bin" files from your game, by tools such as AssetStudioGUI. | |
import os | |
import struct | |
def padFile(f): | |
return f.seek((f.tell() + 3) // 4 * 4) | |
def readString(f): | |
strlen, = struct.unpack("<I", f.read(4)) | |
string, = struct.unpack(f"<{strlen}s", f.read(strlen)) | |
padFile(f) | |
return string | |
l = os.listdir("./") | |
for filename in l: | |
if not filename.endswith(".dat"): | |
continue | |
f = open(filename, "rb") | |
g = open(filename.replace(".dat", ".txt"), "wb") | |
head = f.read(0x1c) | |
namelen, = struct.unpack("<I", f.read(4)) | |
name, = struct.unpack(f"<{namelen}s", f.read(namelen)) | |
padFile(f) | |
count, = struct.unpack("<I", f.read(4)) | |
for i in range(count): | |
name = readString(f) | |
unk, = struct.unpack("<I", f.read(4)) | |
if unk == 1: | |
pass | |
elif unk == 2: | |
f.read(4) | |
else: | |
raise ValueError | |
font = readString(f) | |
text = readString(f) | |
speaker = readString(f) | |
image = readString(f) | |
g.write(name + b'\t' + text.replace(b'\n', b'\\n') + b'\n') | |
f.close() | |
g.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment