Welcome to the Sims 4's API Documentation.
This is a work in progress...

  • Added this page


ts4script files are nothing more than simple archives containing compiled python 3.7 files.

python.exe -m py_compile path_to_your_python_file.py

  1. Compile your python file (or don't, sims recognizes python files if they're packaged).
  2. Use archive software to create a zip file containing your python file.
  3. Rename your archive to yourmodname.ts4script
  4. Move yourmodname.ts4script to you Sims 4 mods folder.



This guide assumes that you're using Matroska's Mod Compiler.

  1. Make sure python 3.7 is installed and set as default.
  2. pip install virtualenv colorama 
  3. python mmc.py (or) mmc.exe

  1. Create a new mod using the C command.
  2. Give your mod a name, then press enter.
  3. Enter your Mod's number, then press enter.


MMC has the ability to "patch" python modules to make them compatibile with Sims 4
[This is done automatically when compiling the mod]
  1. Initiate Virtualenv with the M command.
  2. Enter your mod's number.
  3. pip install any modules.
  4. Use the exit command to return to the main menu.


MMC has the ability to "patch" python modules to make them compatibile with Sims 4.
  1. Initiate Virtualenv with the M command.
  2. Enter your mod's number.
  3. pip install any modules.
  4. Use the exit command to return to the main menu.


  1. Use the C command to compile your mod.
  2. Run The Sims 4 to test it. No need to move any files around.


Debug can be used if you want to add your source code files to the mod.
This is mainly for testing reasons.

You can enable debug mode with the D command.


from sims4.commands import Command, CommandType, CheatOutput
        
    @Command('hello', command_type=CommandType.Live)
    def sayhello(_connection=None):
        output = CheatOutput(_connection)
        output('Hello, world!')
    



Sometimes a mod needs run in a loop. This is a real issue for The Sims 4, and often ends with headaches on loading screen/game boot loops.

Thankfully, Sims 4 has a built-in threading module.
Here's how to use it properly.

(Credit: MatroSka, Pollyetta)

from threading import Thread
# Import sims' threading module

def looping_function():
    """ 
    Any code you want to run in a loop
    should be placed here
    """
    pass

x = Thread(target=looping_function)
"""
create a new thread object, the target 
should be the looping function.
""" 

x.setDaemon(True)
""" 
Setting your thread object as a daemon
is the most important part.
This ensures that it closes when sims closes,
Preventing any boot loops.
""" 

x.start()
# finally, start your thread.