Sims 4 Modding Wiki
Advertisement

The Sims 4 uses XML Tuning to store game data, and Python to interpret that data. Modders can use Python as a basis to create their own XML Tuning (for example, module tuning or test sets), to run a command from the game's console, to store settings, to avoid overriding files, and more. The vast majority of mods can be made without scripting, but scripting is a required element for more advanced mods.


Getting Started[]

To get started with Python scripting, visit this website (S4S Forum Post) to download and install Andrew's starter project for scripting. This tutorial will cover the installation of Python 3.7.0 and PyCharm Community Edition.

Once the starter project is set up, you should mark all folders containing Python code as a sources root, so that PyCharm can help you write code correctly. This includes the base, core, generated, and simulation subfolders in the EA folder, as well as each Scripts folder in your projects. You can mark a directory as a sources root by right-clicking on it and using Mark Directory As > Sources Root. You will know that you've correctly marked the directory when the folder icon turns blue and you no longer see red lines under import statements.


Types of Scripts[]


There are many different kinds of scripts that one may need to write depending on the task at hand. This is not a comprehensive list, but it covers the most common uses for scripts.


Commands[]

Commands are scripts that can either be triggered by the do_command of interaction tuning or the game's cheat console. This includes custom cheat codes.

Injection[]

Injection is an incredibly powerful form of script modding that is used to edit tuning at runtime. Injection may also be used to refer to the act of appending a custom function onto an existing class method, which triggers the modder's script every time the class method is called.

Custom Tuning[]

Custom tuning files can be created with scripts, such as creating custom test sets that can parse original test syntax. This also includes custom module tuning, which can be used to store settings and tuning references for ease of use in other scripts and especially injections.

Settings[]

If a mod requires its own settings, it may do so with a JSON or CFG file which must be parsed with a script.


Scripting Tutorials/Guides[]

Scripting tutorials are the next step to creating a script for The Sims 4. Many of these tutorials aren't easy to find as they are written in forums or on a blog post. This list will link to the various tutorials.

For loose leaf Scripting examples, please look here.

Advertisement