Forum Discussion
8 years ago
For testing purposes (e.g. to try out the script before compiling), you go to your Mods folder and created a folder inside of it called Testing. Then a folder inside of Testing called Scripts. And then put any .py files in the Scripts folder. So it'll look like Mods > Testing > Scripts
For sharing the final product with others, you'll want to compile, to make it into a .pyo file, which can be read by the game without being in the special testing/scripts folder.
To compile, you first want to download Python 3.3. For me, after downloading, it's located in C:\Python33
Put a copy of your scripts in the Python33 folder.
Then I pull up the start menu and in the search box, put in the file path for Python 33, python.exe, and then append -O at the end. So something like this: C:\Python33\python.exe -O
If the path is right, this should bring up an option to open up a python.exe command prompt.
When you've opened the command prompt that comes up, type in;
import myScriptName
Where myScriptName is the name of your script, obviously. :tongue:
And just do that for every script you put in the Python33 folder.
When you're finished, go into __pycache__ folder within Python33 and there should be a .pyo file for each script you compiled. Its name will have some extra stuff in it (I forget the syntax). Just change its name back to what it was originally (with the exception of the file extension, of course).
Now that you have your compiled scripts together, you can put them in a zip file and then change the file extension from .zip to .ts4script (this is just so that it's more clear to people using your mod that the script part is not something they're meant to unzip). Then put it in your Mods folder (*not* within the testing folder this time, since it's compiled and zipped now). I suggest testing it in its compiled form, to be sure compiling went as expected.
Then you're good to go!
For sharing the final product with others, you'll want to compile, to make it into a .pyo file, which can be read by the game without being in the special testing/scripts folder.
To compile, you first want to download Python 3.3. For me, after downloading, it's located in C:\Python33
Put a copy of your scripts in the Python33 folder.
Then I pull up the start menu and in the search box, put in the file path for Python 33, python.exe, and then append -O at the end. So something like this: C:\Python33\python.exe -O
If the path is right, this should bring up an option to open up a python.exe command prompt.
When you've opened the command prompt that comes up, type in;
import myScriptName
Where myScriptName is the name of your script, obviously. :tongue:
And just do that for every script you put in the Python33 folder.
When you're finished, go into __pycache__ folder within Python33 and there should be a .pyo file for each script you compiled. Its name will have some extra stuff in it (I forget the syntax). Just change its name back to what it was originally (with the exception of the file extension, of course).
Now that you have your compiled scripts together, you can put them in a zip file and then change the file extension from .zip to .ts4script (this is just so that it's more clear to people using your mod that the script part is not something they're meant to unzip). Then put it in your Mods folder (*not* within the testing folder this time, since it's compiled and zipped now). I suggest testing it in its compiled form, to be sure compiling went as expected.
Then you're good to go!
About The Sims 4 Mods & Custom Content
Find expert tips, troubleshooting help, tutorials for mods and custom content, and The Sims 4 patch files in our forum.15,847 PostsLatest Activity: 5 seconds ago
Recent Discussions
- 29 seconds ago
- 20 minutes ago
- 2 hours ago