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!
Quick Reply
Search this Thread
Test Subject
Original Poster
#1 Old 5th Sep 2014 at 5:12 PM
Default so.... executing scripts?
So has anybody figured out how the script execution pipeline actually works? Can I just stick scripts into the mods folder and they'll just execute? If so when during the game does that happen?
Advertisement
Test Subject
#2 Old 5th Sep 2014 at 11:17 PM
I am very much a noob at Sims modding, but I managed to get The Sims 4 to recognize my "mod" as a script mod by creating the following directory: ".../The Sims 4/Mods/HelloWorld/Scripts/", with the "Scripts" folder containing a (useless) Python (.py) script:

This may be obvious to some people, but I couldn't find it anywhere. I discovered this when I saw TS4.exe query all the subfolders in the /Mods/ folder for a folder called "Scripts" (using procmon.exe) so I figured that's where it looks for its scripts.
I'm more of a C/C++ guy and I'm not sure how exactly The Sims 4 executes the scripts (or what the script should contain for that matter), but I'm going to try and find out.
Eminence Grise
#3 Old 6th Sep 2014 at 1:25 AM
Quote: Originally posted by Mayco
I am very much a noob at Sims modding, but I managed to get The Sims 4 to recognize my "mod" as a script mod by creating the following directory: ".../The Sims 4/Mods/HelloWorld/Scripts/", with the "Scripts" folder containing a (useless) Python (.py) script:

This may be obvious to some people, but I couldn't find it anywhere. I discovered this when I saw TS4.exe query all the subfolders in the /Mods/ folder for a folder called "Scripts" (using procmon.exe) so I figured that's where it looks for its scripts.
I'm more of a C/C++ guy and I'm not sure how exactly The Sims 4 executes the scripts (or what the script should contain for that matter), but I'm going to try and find out.


There's a lil info on this in the Mods section of the official SIms forum... search for posts by SimGuruModSquad... he (or they) has provided some high level information about script modding.
Test Subject
#4 Old 6th Sep 2014 at 4:21 AM
Quote: Originally posted by Srikandi
There's a lil info on this in the Mods section of the official SIms forum... search for posts by SimGuruModSquad... he (or they) has provided some high level information about script modding.


Thanks. I'm not insane (well at least not related to this). The game doesn't currently load python scripts on initialization and requires a patch before it will do that.

Quote: Originally posted by SimGuruModSquad
- The game will not currently execute new scripts out of the Mods directory when python is initialized. You can work around this by replacing Maxis-authored scripts to inject your code.


I had just finished hacking together a dll injection routine which does exactly this and was checking to see if anything was posted for updates. Hate to tease but looks like a real solution is coming and I'm concerned mine might be the cause of instability I'm seeing so no plans on releasing it. Though maybe it would be useful for doing the __debug__ check without having to hex edit the dlls.
Test Subject
#5 Old 6th Sep 2014 at 7:21 AM
I've done a quick test with an old TS3 package -- the game *appears* to recognize packages, if not individual scripts. Until the repair patch, that's probably about as good as we're going to get.
Test Subject
#6 Old 6th Sep 2014 at 8:48 AM Last edited by nonono1989 : 6th Sep 2014 at 10:05 AM.
some modules like clock_commands are detected and imported (import clock_commands) while module clock is not found... why?
Test Subject
Original Poster
#7 Old 6th Sep 2014 at 10:13 AM
Quote: Originally posted by Srikandi
There's a lil info on this in the Mods section of the official SIms forum... search for posts by SimGuruModSquad... he (or they) has provided some high level information about script modding.

Yeah I searched through their posts on the official modding forums. Perhaps I didn't look quite far enough.

Thanks for the info, guys.
Test Subject
#8 Old 6th Sep 2014 at 10:40 AM
After a while i managed to import few libraries but when i wanted to import sims4.commands i stopped at :

ImportError: No module named '_math'
ImportError: No module named '_trace'

I cannot find this module anywhere so... yeah.
Test Subject
#9 Old 6th Sep 2014 at 4:47 PM
Those modules are not actual python. They are included within the game. Python allows both C-to-Python and Python-to-C and these are the Python-to-C variety.

Here is the list I have compiled so far that are internalized. I just created a bunch of files that are empty stubs to allow my IDE to not complain about the imports. You cannot import these from standalone python and can only be run from within the game (unless you create adequate simulations of what they are doing).

_animation, _common_types, _filemonitor, _geometry, _hashutil, _math, _pythonutils, _resourceman, _sims4_collections, _trace, _weakrefutils
Back to top