Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Test Subject
Original Poster
#1 Old 4th Jan 2021 at 7:02 PM
Default Python question
Is it possible to get the filename of an object in game using python? I suppose this would mostly work with CC

What I have set up is using a pie menu selecting an object I'm doing a dump of the object info and well, not seeing anything pointing to a filename. Didn't think it would be that easy anyways...

Code:
def _object_info(self, timeline):
        output = ""
        result = self.target.definition
        for att in dir(result):
            if hasattr(result, att):
                output = output + "\n<b>" + str(att) + "</b>: " + clean_string(str(getattr(result, att)))
        if hasattr(self.target, "scale"):
            scale = self.target.scale
        else:
            scale = 1
        info_string = "Object Name: {}\n" \
                    "Object ID: {}\n" \
                    "Object Scale :{}\n" \
                    "Object POS: X:{} Y:{} Z:{}\n" \
                    "Type: {}\n" \
                    "Info: {}" \
                    .format(self.target.__class__.__name__,
                    self.target.definition.id,
                    scale,
                    self.target.location.transform.translation.x,
                    self.target.location.transform.translation.y,
                    self.target.location.transform.translation.z,
                    self.target.__class__.__name__,
                    output)
        notice(None, "Object Info", info_string, False, "GREEN"))
Advertisement
Lab Assistant
#2 Old 6th Jan 2021 at 10:01 AM
"filename of an object in game" - You mean the tuning file of the object? The definition file of the object? Or perhaps you're talking about the package file that contains the tuning file or the definition file of the object?

Both the definition and the class name return you the names of the files that construct the object itself. Because objects are made out of many different files, you must be talking about the package that contains some file of the object, let's say the tuning file. If that's the case then there is no way to do it with the default methods the game code offers. For that, and really only doable for mods, you would need to scan each and every package file manually and search their indexes for the file ID you're looking for. Of course I mean that you need to make your own custom code for loading package files and reading them.
Test Subject
Original Poster
#3 Old 6th Jan 2021 at 4:34 PM
Quote: Originally posted by TURBODRIVER
For that, and really only doable for mods, you would need to scan each and every package file manually and search their indexes for the file ID you're looking for. Of course I mean that you need to make your own custom code for loading package files and reading them.


Yeah the package file and I was hoping I didn't have to do that, even though I could. Not gonna happen lmao. I was hoping I overlooked something. Thanks for the help!
Back to top