https://medium.com/swlh/the-sims-4-modern-python-modding-part-4-replacing-class-code-41fde4283f98
What we’re going to do is replace another piece of code to get more practice at it and we’re going to step it up a small bit to make thing just a tiny bit more challenging.
This tutorial was fairly difficult to make happen because it took a long time to track down the needed code and then go through the many road blocks that happened. I’d say it took me close to three days to get to this point and quite a bit of frustration, just remember patience and practice is key to mastering Sims 4 python scripting.
I feel this tutorial is a bit dense. The program we’re making is a little over 25 lines of code, however it really goes into a lot of explanation and breaks everything down properly. Please take it slow to understand each section and ask questions if you have any.
The projects here assume your up-to-speed on how to mod for the Sims 4 using python scripting which I already covered. If you’re new to this series I encourage you to start at part 1.
We are going to be creating a mod called “Whimsical Charges” where the service pricing for maids, repair people, and even pizza are a bit more looser than advertised.
If it sounds complicated don’t worry it’s actually not especially if you’ve been following along up until now. In part 3 you learned how to replace regular function code and here you’re going to learn how to replace class code specifically marked @ classmethod
which has to be replaced a tad differently. We’re also going to cover managing a variable and allowing it to be changed from the cheat console.
To save you hours of code searching, we’re going to start in simulation/situations/service_npcs/service_npc_tuning.py
which translates to the package situations.service_npcs.service_npc_tuning
. Inside that file is code related to Service NPCs and we’re interested in a class called ServiceNpcHireable
There’s one little method inside this class which is what we’re interested in replacing.
A few things to note:
cost_up_front
and cost_hourly
are inside cls.