Replies: 1 (Who?), Viewed: 5425 times.
Lab Assistant
Original Poster
#1 Old 19th Sep 2014 at 11:19 PM Last edited by DarkWalker : 14th Aug 2015 at 4:05 AM.
Default CSV list of IDs, names, and tuning names and IDs of objects
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.

Code:
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()


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.
Download - please read all instructions before downloading any files!
File Type: 7z obj_list.7z (70.4 KB, 428 downloads) - View custom content
File Type: 7z List_1.10.7z (185.1 KB, 311 downloads) - View custom content
Description: IDs, in hex and decimal, plus the internal names and (for objects) the tuning name for all CASP items and objects. Patch 1.10 with all expansions.
Advertisement
Pettifogging Legalist!
retired moderator
#2 Old 2nd Nov 2014 at 2:28 PM
Moving to Resources.

Stuff for TS2 · TS3 · TS4 | Please do not PM me with technical questions – we have Create forums for that.

In the kingdom of the blind, do as the Romans do.
Back to top