Forum Announcement, Click Here to Read More From EA_Cade.

Please Help With Scripting

Hey guys,

I'm REALLY wanting to get into modding The Sims 4. Does anyone know any good tutorials purely focused on scripting?

xPaxion

Comments

  • Forest_NinjaForest_Ninja Posts: 1,181 Member
    Hello @xPaxion ,

    To begin scripting The Sims 4 you'll need the following: You'll need to download and install the python development kit first, so click on the first link and download version 3.5.2. Ensure that you select the option to add the path to your environment variables or you'll have to enter the full path when working with scripts.

    You'll need to familiarize yourself with the package and data structure of The Sims 4 since you'll need to locate and associate data by context, and work with tuned instances which are created from packaged data during initialization of worlds. Download S4PE from github and the XML extraction utilities from ModTheSims.

    You'll need to learn the native functions of python and basic scripting so you can either study the python documentation, search for entry level tutorials, or study the game scripts and fumble through them (not recommendable).

    You'll need to learn best coding practices since The Sims 4 is very delicately balanced and excessive looping or heavy data queries will cause the engine to freeze during execution. This might be acceptable if you're only using the scripts to export data or configure your neighborhood, however, if you're creating mods which will be used during normal gameplay, overloading the engine with loops, data queries, or console output, is inadvisable. Even a few thousand lines of console output while searching for objects can hang or crash the game engine. If you can't find anyone who is willing to teach best practices, feel free to ask here in the forums under "Mods & CC Technical Discussions."

    Extract the content of the three zip archives that I've mentioned above into a directory where they can be left untouched and ensure that winzip is configured to preserve the original directory structure. You'll need to know the original paths when importing functions if you don't intend to override them all. Transfer the scripts to be decompiled and edited into a working directory, and I'd recommend creating your own rather than editing and re-packaging theirs.

    Experiment with some of the smaller scripts which are already available so you can understand how the game reads packaged data and scripts which are placed in your mods directory. Once you've learned to compile and execute python scripts, I would recommend searching for the resource lists and learning to use file I/O since you won't be able to do anything without definition lists and the tuned instance managers. You should create a test save with no scripts other than your own enabled since the released version of the game engine offers no debugging functionality of any kind and you'll be forced to re-launch the engine with every test if it's necessary to test for context or search data. Console Output, file.write, and your own intelligence are your best debugging tools.

    Python is sensitive to spacing and file encoding so you must use a plain text editor and manually indent every line of your script if you paste even a single line from a decompiled script. Ensure that there are no spaces before your imports or after the last return, and that every line is perfectly indented. If you've pasted a line with a for loop or if statement which is indented with spaces after you've indented every other line with tabs, the compiler will return an error.

    The first thing you should test is creation of live commands and there are plenty of examples. The language is standardized and should be easy to understand if you have any programming experience.

    Enjoy your scripting and the new world which you'll immediately discover!
    "Video gaming began as an engineer's hobby and a means of creative expression for those of higher technical inclination. It is expected that those who are capable of higher engineering-related achievements will see value, in electronic entertainment products, where others see failure." -Sasquatch
Sign In or Register to comment.
Return to top