PDA

View Full Version : CSV list of IDs, names, and tuning names and IDs of objects


DarkWalker
19th Sep 2014, 10:19 PM
I was toying a bit with the files referenced as object definition in the custom content guide (type 0xc0db5ae7); they have inside a label and, if they reference a tuning, also the tuning label and ID.

There are over 10k such files, though; manually creating a list would be one huge pain in the ass. So I created a small python script to output a CSV file with the labels and IDs I was looking for.

The script is just below; it's a quick hack, but it works well for files extracted by S4PE.

I've attached the resulting text file from running it on every type 0xc0db5ae7 file extracted from SimulationFullBuild0.package. My main use for it is to find the binary files of an object I already have the tunings for. Each line has the file ID in both hex and decimal (the decimal IDs are used in tuning files to create objects), the label of the object, and if there is a tuning reference the tuning label and its ID.

How to use: extract all type 0xc0db5ae7 files you want to generate the list from to a single folder, adjust the directory variable in the script below to point to the extracted files, change the path of the output file to something that will work for you (I doubt many of you keep a ramdrive at x: ), and run the script. Changing printall to 0 will skip files that don't reference a tuning. I've tested it under python 3.3.5, which is the same used for modding Sims 4 scripts.


import os, struct
from pprint import pprint

directory = 'C:/PathToFilesOfType0xc0db5ae7/'
extension = '.bnry'

out = open('x:/obj_list.txt', 'w')
printall = 1

for file in os.listdir(directory):
if file.endswith(extension):
f = open(directory+file, 'rb')
m1 = struct.unpack('H', f.read(2))[0]
m2 = struct.unpack('I', f.read(4))[0]
s1 = struct.unpack('I', f.read(4))[0]
name1 = f.read(s1).decode('ascii')
s2 = struct.unpack('I', f.read(4))[0]
if s2 > 4:
name2 = f.read(s2).decode('ascii')
id = struct.unpack('I', f.read(4))[0]
if printall or s2 > 4:
out.write(file[21:21+16]+","+str(int(file[21:21+16],16))+","+name1)
if s2 > 4:
out.write(","+name2+","+str(id))
if printall or s2 > 4:
out.write("\n")

out.close()


:mod: Edit: found a way to semi-autonomously extract this info from the game without having to manually extract the files (by implementing .package extraction in python 3.3), so I can now provide this information far more easily. I'm attaching an updated version of the file, with all objects and CASP items from patch 1.10 with all expansions. I can also provide the scripts I'm using, but those are a work in progress and currently kinda messy.

plasticbox
2nd Nov 2014, 2:28 PM
Moving to Resources.