|
Post by frankk on Apr 9, 2021 9:08:28 GMT -5
Hello! Firstly, thanks a bunch for the starter project, Andrew - it makes things very easy. However, there is a small issue I noticed in the compiling code a while back, and figured I would leave a note about it here in hopes that you can update the project.
The issue comes up when modders organize their scripts into packages. The `compile_module` function in `Utilities/__init__.py` compiles every package once, including all of its subpackages. This results in duplicated files in the compiled ts4script. So, if you have the following package structure:
package_A - file_1 - package_B --- file_2 - package_C --- file_3
The compiled ts4script will contain 2 copies of each file_2 and file_3, and one copy of file_1. The duplicated code can, and in most cases will, cause issues. The fix for this is quite simple, I've been using it since I started modding and it's never failed me. If you replace the following:
for folder, subs, files in os.walk(src): zf.writepy(folder)
with simply this:
zf.writepy(src)
It will compile all of the scripts correctly, both with and without packages: `writepy` already compiles the entire directory and all of its children, so the `for` loop is redundant in this case. I've mentioned this change to quite a few people when I help them get started with scripting, so it'd be great to have this change in the project itself! Thanks.
Another very small note, but it'd also be nice to note that if you change `optimize=2` to `optimize=1` in the PyZipFile, it will leave in docstrings. This is another good change because it allows modders to leave in documentation and terms of use notices for anyone who happens to decompile their scripts.
(P.S. Also, the `compiler.py` file isn't actually used for anything, so you can probably get rid of it. Whenever you import Utilities, you're just using the code in `Utilities/__init__.py`, which is exactly the same as `compiler.py`)
|
|
|
Post by isabel2 on May 23, 2021 2:04:24 GMT -5
Where do I go after this? Is there any documentation for scripting? How do I make what I wanna make now?
|
|
|
Post by frankk on May 25, 2021 7:11:39 GMT -5
Where do I go after this? Is there any documentation for scripting? How do I make what I wanna make now? Depends on what you want to make - most mods do not actually require a script, and many common scripting tasks can be achieved through tuning by using XML Injector by Scumbumbo and TriplisThere is no documentation for Sims 4 scripting, but there are some script tutorials available. The best way to learn scripting for TS4 is to look through the decompiled code and experiment for yourself, but you can also ask other modders for help, we're very active on Discord. The Creator Musings server for example is a great resource: discord.gg/qxz5Kn5
|
|
|
Post by thedreamersims on Sept 27, 2021 9:52:31 GMT -5
Hi, new aspiring modder here. I'm Bri. I am stuck at the decompile portion. It does not decompile and I get three errors. I'm using a windows MSI laptop. Not sure if that's needed, but wanted to let that be known just in case My mods folder is located in documents but the Program Files are located in the exact same place as the settings already were so I didn't change anything. I don't know if i am supposed to, I'm new to python as a whole and I'm trying to learn as I go. The Error: Traceback (most recent call last): File "C:\Users\B\Desktop\Sims 4 Python Script Workspace\decompile_all.py", line 1, in <module> from Utilities import extract_folder File "C:\Users\B\Desktop\Sims 4 Python Script Workspace\Utilities\__init__.py", line 6, in <module> from Utilities.unpyc3 import decompile File "C:\Users\B\Desktop\Sims 4 Python Script Workspace\Utilities\unpyc3.py", line 77, in <module> SETUP_LOOP, BREAK_LOOP, CONTINUE_LOOP, NameError: name 'SETUP_LOOP' is not defined Process finished with exit code 1 This is what I changed the settings.py to: import os
creator_name = 'Simplybrix'
mods_folder = os.path.expanduser(
os.path.join('~', 'Documents', 'Electronic Arts', 'The Sims 4', 'Mods')
)
game_folder = os.path.join('C:', os.sep, 'Program Files (x86)', 'Origin Games', 'The Sims 4')
As you can see, I really didn't change anything. :/ Thanks in advance for your help.
|
|
|
Post by peter1011 on Jan 21, 2022 5:32:36 GMT -5
Hello, I'm not new to python but I'm new to mod creation. I'm looking for a way to create an extended pie menu from every sim computer which can:
1. adjust funds households (deduct and add) 2. get information from the real world internet like weather temperature (via API pipe)
Which tutorial should I go to?
Many thanks!
|
|
|
Post by peter1011 on Jan 21, 2022 11:12:16 GMT -5
I have python 3.7.4 and run it, the compiler seems fine. But nothing shows up on the cheat screen, what happens?
|
|
|
Post by rcmxnn on Jun 20, 2022 18:14:25 GMT -5
Hi there! I know that this is an older forum but I thought I would try anyways to see if I might get some help. I am working on a Macbook Pro. I got up to step 8 and have been experiencing an issue with decompling the files. Now, I know I might have done something wrong with the path file when adding an interpreter but I am not sure what and I cannot find any help because I do not know what exactly the problem is only that I am not getting the correct reponse when trying to run the decompile.py
/usr/local/bin/python3.10 "/Users/myname/Desktop/poo for Python/Sims 4 Python Script Workspace/decompile_all.py" Traceback (most recent call last): File "/Users/myname/Desktop/poo for Python/Sims 4 Python Script Workspace/decompile_all.py", line 1, in <module> from Utilities import extract_folder File "/Users/myname/Desktop/poo for Python/Sims 4 Python Script Workspace/Utilities/__init__.py", line 6, in <module> from Utilities.unpyc3 import decompile File "/Users/myname/Desktop/poo for Python/Sims 4 Python Script Workspace/Utilities/unpyc3.py", line 77, in <module> SETUP_LOOP, BREAK_LOOP, CONTINUE_LOOP, NameError: name 'SETUP_LOOP' is not defined
That is the issue I am seeing. If anyone has any tips I would be very greatful.
|
|
|
Post by MizoreYukii on Jun 20, 2022 21:27:08 GMT -5
Hi there! I know that this is an older forum but I thought I would try anyways to see if I might get some help. I am working on a Macbook Pro. I got up to step 8 and have been experiencing an issue with decompling the files. Now, I know I might have done something wrong with the path file when adding an interpreter but I am not sure what and I cannot find any help because I do not know what exactly the problem is only that I am not getting the correct reponse when trying to run the decompile.py /usr/local/bin/python3.10 "/Users/myname/Desktop/poo for Python/Sims 4 Python Script Workspace/decompile_all.py" Traceback (most recent call last): File "/Users/myname/Desktop/poo for Python/Sims 4 Python Script Workspace/decompile_all.py", line 1, in <module> from Utilities import extract_folder File "/Users/myname/Desktop/poo for Python/Sims 4 Python Script Workspace/Utilities/__init__.py", line 6, in <module> from Utilities.unpyc3 import decompile File "/Users/myname/Desktop/poo for Python/Sims 4 Python Script Workspace/Utilities/unpyc3.py", line 77, in <module> SETUP_LOOP, BREAK_LOOP, CONTINUE_LOOP, NameError: name 'SETUP_LOOP' is not defined That is the issue I am seeing. If anyone has any tips I would be very greatful. Might not solve your problem, but make sure to switch to 3.7, 3.10 is not supported by the game. Frankk posted this for Mac users in my creator help server, unsure if this will solve your issue though:
|
|
|
Post by sherimyler on Jul 7, 2022 17:27:04 GMT -5
I'm new to Python and trying to make mods.
Upon reaching step 8:
"8. Before trying to create a script of your own, it is best to first extract the ones from the game. Not only can you look to them for examples, but also having them extracted will allow PyCharm to assist you while creating your own scripts. To extract the game scripts, right-click the decompile_all.py and select "Run 'decompile_all'". You will see a log at the bottom of the screen written for each decompiled file. Wait until it has finished before continuing to the next step."
I click to "Run `decompile.all`" and get the following error message:
"NameError: name 'SETUP_LOOP' is not defined
Process finished with exit code 1"
The full text in the box at the bottom is:
"C:\Users\User\AppData\Local\Programs\Python\Python310\python.exe "C:/Users/User/OneDrive/Desktop/Python/Sims 4 Python Script Workspace/decompile_all.py"
Traceback (most recent call last):
File "C:\Users\User\OneDrive\Desktop\Python\Sims 4 Python Script Workspace\decompile_all.py", line 1, in <module>
from Utilities import extract_folder
File "C:\Users\User\OneDrive\Desktop\Python\Sims 4 Python Script Workspace\Utilities\__init__.py", line 6, in <module>
from Utilities.unpyc3 import decompile
File "C:\Users\User\OneDrive\Desktop\Python\Sims 4 Python Script Workspace\Utilities\unpyc3.py", line 77, in <module>
SETUP_LOOP, BREAK_LOOP, CONTINUE_LOOP,
NameError: name 'SETUP_LOOP' is not defined
Process finished with exit code 1"
I tried deleting and re-downloading the three programs from the links and restarting my laptop, to no avail.
I'd be grateful for any help.
|
|
|
Post by jarilive on Jul 11, 2022 13:23:45 GMT -5
Hi, I have seen that multiple people had this issue, and I have the same, but I haven't seen any way to fix it.
Does someone know how I can fix this error?
"C:\Users\jarid\AppData\Local\Programs\Python\Python37\python.exe "C:/Users/jarid/Documents/De Sims 4 Meuk/Pycharm Sims Project Folder/Sims 4 Python Script Workspace/My Script Mods/Example Mod/compile.py" Traceback (most recent call last): File "C:/Users/jarid/Documents/De Sims 4 Meuk/Pycharm Sims Project Folder/Sims 4 Python Script Workspace/My Script Mods/Example Mod/compile.py", line 5, in <module> compile_module(creator_name, root, mods_folder) File "C:\Users\jarid\Documents\De Sims 4 Meuk\Pycharm Sims Project Folder\Sims 4 Python Script Workspace\Utilities\__init__.py", line 62, in compile_module shutil.copyfile(ts4script, ts4script_mods) File "C:\Users\jarid\AppData\Local\Programs\Python\Python37\lib\shutil.py", line 121, in copyfile with open(dst, 'wb') as fdst: FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\jarid\\Documents\\Electronic Arts\\The Sims 4\\Mods\\JariLive_Example Mod.ts4script'
Process finished with exit code 1"
It isn't a that big issue since I can move the file myself but it would be nice if I wouldn't need to do that.
Thanks in advance!!
|
|
|
Post by shreditdude on Aug 5, 2022 2:57:34 GMT -5
I'm new to Python and trying to make mods. Upon reaching step 8: "8. Before trying to create a script of your own, it is best to first extract the ones from the game. Not only can you look to them for examples, but also having them extracted will allow PyCharm to assist you while creating your own scripts. To extract the game scripts, right-click the decompile_all.py and select "Run 'decompile_all'". You will see a log at the bottom of the screen written for each decompiled file. Wait until it has finished before continuing to the next step." I click to "Run `decompile.all`" and get the following error message: "NameError: name 'SETUP_LOOP' is not defined Process finished with exit code 1" The full text in the box at the bottom is: "C:\Users\User\AppData\Local\Programs\Python\Python310\python.exe "C:/Users/User/OneDrive/Desktop/Python/Sims 4 Python Script Workspace/decompile_all.py" Traceback (most recent call last): File "C:\Users\User\OneDrive\Desktop\Python\Sims 4 Python Script Workspace\decompile_all.py", line 1, in <module> from Utilities import extract_folder File "C:\Users\User\OneDrive\Desktop\Python\Sims 4 Python Script Workspace\Utilities\__init__.py", line 6, in <module> from Utilities.unpyc3 import decompile File "C:\Users\User\OneDrive\Desktop\Python\Sims 4 Python Script Workspace\Utilities\unpyc3.py", line 77, in <module> SETUP_LOOP, BREAK_LOOP, CONTINUE_LOOP, NameError: name 'SETUP_LOOP' is not defined Process finished with exit code 1" I tried deleting and re-downloading the three programs from the links and restarting my laptop, to no avail. I'd be grateful for any help. From the look of it, it looks like you're using Python 3.10 C:\Users\User\AppData\Local\Programs\Python\Python310\python.exe You'll have to download Python 3.7. I use 3.79 and decompiling works fine.
|
|
|
Post by etherias on Aug 9, 2022 5:47:09 GMT -5
Hello!! I also had this error
from Utilities import compile_module ModuleNotFoundError: No module named 'Utilities'
I solved it by adding in decompile_all.py and compile.py the following lines before imports
import sys sys.path.append('C:/Users/your path to/Sims 4 Python Script Workspace') Hope it can help someone
|
|
neowbr
New Member
Hi, I'm new to modding
Posts: 7
|
Post by neowbr on Dec 16, 2022 17:35:53 GMT -5
I'm trying to do the python scripting tutorial, but when I get to the part to run the compile.py, but when I run mine it says FileNotFoundError, should I ignore this?
C:\Users\me\AppData\Local\Programs\Python\Python37\python.exe "C:\Users\me\OneDrive\Documents\Electronic Arts\ProjectFolder\Sims 4 Python Script Workspace\My Script Mods\Example Mod\compile.py"
Traceback (most recent call last):
File "C:\Users\me\OneDrive\Documents\Electronic Arts\ProjectFolder\Sims 4 Python Script Workspace\My Script Mods\Example Mod\compile.py", line 5, in <module>
compile_module(creator_name, root, mods_folder)
File "C:\Users\me\OneDrive\Documents\Electronic Arts\ProjectFolder\Sims 4 Python Script Workspace\Utilities\__init__.py", line 62, in compile_module
shutil.copyfile(ts4script, ts4script_mods)
File "C:\Users\me\AppData\Local\Programs\Python\Python37\lib\shutil.py", line 121, in copyfile
with open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\me\\Documents\\Electronic Arts\\The Sims 4\\Mods\\neowbr_Example Mod.ts4script'
Process finished with exit code 1
I've been at this for days and I really want to complete a tutorial, the last one I tried didn't work and with this one I'm just a step away. So, could someone help me please?
|
|
|
Post by blackmoonsims on Jan 25, 2023 8:14:14 GMT -5
I'm trying to do the python scripting tutorial, but when I get to the part to run the compile.py, but when I run mine it says FileNotFoundError, should I ignore this? C:\Users\me\AppData\Local\Programs\Python\Python37\python.exe "C:\Users\me\OneDrive\Documents\Electronic Arts\ProjectFolder\Sims 4 Python Script Workspace\My Script Mods\Example Mod\compile.py" Traceback (most recent call last): File "C:\Users\me\OneDrive\Documents\Electronic Arts\ProjectFolder\Sims 4 Python Script Workspace\My Script Mods\Example Mod\compile.py", line 5, in <module> compile_module(creator_name, root, mods_folder) File "C:\Users\me\OneDrive\Documents\Electronic Arts\ProjectFolder\Sims 4 Python Script Workspace\Utilities\__init__.py", line 62, in compile_module shutil.copyfile(ts4script, ts4script_mods) File "C:\Users\me\AppData\Local\Programs\Python\Python37\lib\shutil.py", line 121, in copyfile with open(dst, 'wb') as fdst: FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\me\\Documents\\Electronic Arts\\The Sims 4\\Mods\\neowbr_Example Mod.ts4script' Process finished with exit code 1 I've been at this for days and I really want to complete a tutorial, the last one I tried didn't work and with this one I'm just a step away. So, could someone help me please? I haven't done this tutorial yet myself and I'm a complete noob when it comes to scripting and python, but do you have an option in your file explorer called This PC? That's the main folder that pops up when I use my computer and do things on it. It's similar to the users\me\documents way and has all the same stuff, but maybe it won't error out if you use that.
If you have windows 10 and your file explorer shows:
-quick access -One Drive -This PC
on it's side panel, just click the documents option under This PC and navigate to -->electronic arts>The Sims 4>Mods for the directory location. I hope this works.
Edit: OH also, you are navigating to your one drive location for the python script. Did you save it on your computer hard drive or just in the cloud? Instead of using the cloud to do this, try navigating directly to the python script workspace location on your hard drive.
If you've already figured this out, you can ignore me XD
|
|
|
Post by heatherliis on Feb 10, 2023 8:40:32 GMT -5
I'm a total newbie and managed to complete one of the tutorials on python script reloading in the Sims 4 game without having to restart the whole game. But I have one question though: is there any way to reload package files in the Sims instead of just python files? I hope that's not a lame question. I've been learning how to make traits and it would be so much faster to test them by using the reload script instead of restarting the game. I do hope to learn more about making mods. Here is the tutorial that I completed and IT DOES WORK for py files. I just wish it would for package files. medium.com/swlh/the-sims-4-modern-python-modding-part-5-project-template-c9ffee48ab4eIf I missed something and someone already asked this, I do apologize. Thank you, Heather
|
|