https://medium.com/analytics-vidhya/the-sims-4-modern-python-modding-part-2-hello-world-77c5bfd3ce4e

In this part we’re going to create a mod that prints Hello World to the console. This gets you familiar with the process of writing the code and converting it into a mod that can run inside the game. It also familiarizes you with the Sims 4 python library that we decompiled in part 1 and I briefly talked about.

This part assumes you have finished part 1, if not, you need to read through and go through part 1.

The simplest program we can make

Let’s make the overly common “Hello World” program which is only 6 lines. This program will output to the cheat console the words “Hello World” when you type in a command.

The brutal reality of python scripting for Sims 4 mods

Notice a few keywords in the paragraph above — “output”, “cheat console”, “command”. In order to make a mod, you need to know what to make and read the official documentation and notes in the code that EA gives you… Except EA is among very few companies that has decided to not give you any help, notes, documentation, or code for using their modding system so you’re left scavenging through obscure files and code and all you can go on is the names of the files and and to look through complicated obscure contents to try and figure out how it works.

This is important to know because this is the entirety of python script modding for Sims 4. You’re completely on your own, apart from asking around on forums and hoping to get a good answer or answer at all, you don’t have anything to go on and to do the simplest thing could take hours of digging through obscure files and hundreds of lines of code trying to make sense of things.

Finding the pieces to this Hello World mod

Thankfully I can guide you through the initial waters of finding the information you need and bringing together this mod. The first thing we want to do is to allow us to interact with our script through the cheat console so that’s a starting point.

Out of the 3 folders I mentioned in part 1, which do you think would house such code.

Even better, since we know exactly what we’re looking for. Lets do a search across all the folders and files to save us some time. Poking through the files is great for exploring and getting ideas but in other cases a search can save a lot of time.

So I found something interesting. There’s many cases of what looks to be scattered code that registers cheat codes. Do you see the

@ sims4.commands.Command(‘…’, …

This is littered throughout the Sims 4 code base and clearly this is how you register a cheat code. This is exciting then because the initial step to what we want to do then seems very easy and not as complicated as I might have imagined it’d be.