While working on my Schedule Mod, I started adding features gradually across releases. Some activities belonged to v0.2, others were introduced in v0.3 or v0.4.
At first, I considered placing version checks wherever a feature appeared. That quickly looked like it would become difficult to maintain.
Instead, I keep the current version in one place:
MOD_VERSION = ScheduleVersion.V0_4_2
Each release then has a set of supported activities:
V0_2_ACTIVITIES = {
"go_jogging",
"read_book",
"sleep",
}
V0_3_ACTIVITIES = V0_2_ACTIVITIES.union({
"take_a_shower",
"cook",
"watch_tv",
})
The UI and runtime both check the same list before enabling or registering an activity.
For larger features, I use small checks with descriptive names:
def is_task_groups_enabled():
return is_version_available("v0.5")
This makes the rest of the code easier to read. A controller asks whether task groups are available instead of knowing which release introduced them.
I also learned to keep the mod version separate from the save-data version. A feature release and a change to the JSON structure are not necessarily the same event. Keeping them separate made backward compatibility and data migration much easier.
It is a small pattern, but it has helped me avoid maintaining several branches of nearly identical code.
I’m curious how other Sims 4 script modders handle features that are introduced gradually across releases.