- Site Map >
- Modding and Creation >
- Sims 4 Creation >
- Modding Discussion >
- Python question
- Site Map >
- Modding and Creation >
- Sims 4 Creation >
- Modding Discussion >
- Python question
Replies: 2 (Who?), Viewed: 542 times.
#1
4th Jan 2021 at 7:02 PM
Posts: 29
Python question
Is it possible to get the filename of an object in game using python? I suppose this would mostly work with CCWhat 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
#2
6th Jan 2021 at 10:01 AM
Posts: 156
Thanks: 24339 in 36 Posts
"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.
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.
#3
6th Jan 2021 at 4:34 PM
Posts: 29
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!
Who Posted
|