https://medium.com/swlh/the-sims-4-modern-python-modding-part-5-extending-lists-fdc9dcb67980
This is going to be a much easier and shorter tutorial and a bit more fun. You’re going to learn how to extend an in-game list. Extending a list is much safer because it’s often the least likely to conflict with other mods because we’re not replacing anything yet can add additional options or functionality to the entire game.
As briefly mentioned in part 4, there’s an official list of words/strings considered to be “true” and another list for “false”. These 2 lists are used in any command that takes a yes or no / true or false argument. Most mods don’t seem to use the list unfortunately but any that do will automatically be using the extended list. For this tutorial, we’re going to extend both of those lists.
The projects here assume your up-to-speed on how to mod for the Sims 4 using python scripting which I already covered in part 1 & part 2.
I’ve created a boilerplate / template project to help automate compiling, decompiling, packaging, etc… Link Here. And I tried my best to make it cross-platform and editor agnostic. If you’re about to start a new project and your interested in a template that lays out the groundwork for you then this would be that. Completely optional but there if your interested.
In fact I wrote a whole tutorial on how to use it, link here
I basically poked around the internet and gathered a large list of words that we’ll be using. Many forms of yes and no are local to your country and area so because I’m in America we’ll be pulling words from there.
Normally though you’d want to have the list in a data file like JSON or XML and have many of them for different countries so that users can extend them themselves and all countries are included and the correct list is loaded based on the language of the player. — However that’s fairly complicated this early in the series so we’re going to shortcut and just pick a country and language. In the future, always keep in mind your audience. You never want to exclude people who may want to use your mod and in 2020 there are many established systems people have come up with related to localization to solve exactly that.
Because the list is very large I’m going to place them in pastebin because I don’t want to fill up the articles with pages of words. You’re welcome to extend the list and add/or remove words.
Link to the list of words.
We import both the lists of true
and false
. Also be sure to copy the code here which contains all the words for both lists.
from sims4.commands import BOOL_TRUE, BOOL_FALSE
And then tell python to merge our lists into the official lists
You’re code should look like this, many entries omitted to keep article size down.