8 years ago
Verify_School logic not making sense
I figured maybe talking about this will reveal something I'm not seeing. Last night I revisited the mod I'd made that allows Child and Teen Sims to Quit or Rejoin School. I'd managed to use a script, so that the game no longer pushed school on you, either when loading or when aging up.
But someone pointed out to me a glaring flaw in this, that without having school pushed on you when you age up, unplayed sims would simply never join it or go there, unless you switched to them and joined manually.
This was a good reason, I felt, to try to revisit separating the two, so that it's only loading where the game no longer pushes school on you and aging up still does.
I tried some different approaches last night, searched files, studied the code, but the logic simply didn't make sense.
The code for the Verify_School method is as follows (from sim_info.py):
Then in sim.py, there's this:
And in aging_mixin.py, in the advance_age method, there's this:
These are the only two places, a search shows, where the verify_school method is called. And the method that verify_school calls ("update_school_career()") is only called within sim_info.py
It appears fairly intuitive to me. The call in aging_mixin checks if the sim is aging up to something past Toddler. If they are, verify_school is called. Verify_school checks if the sim in question is a child or teen and generates their little homework booklet if they are. At the end, it calls update_school_career no matter what, which calls this:
To verify that their age is Child or Teen and pass along the appropriate school career to be added to them.
The part where my understanding breaks down is this:
1) I can't seem to figure out what "self._time_sim_was_saved is None" actually means and how it relates to the code in sim.py. I'm guessing it relates to it for some reason.
2) It appears that the code in sim.py is passing along the value to verify_school "from_age_up=false" (because it's not from aging up, it's from loading) and the code in aging_mixin.py is passing along the value to verify_school "from_age_up=true" (because it is from aging up).
And yet, if I change the verify_school method to something like this:
It doesn't appear to do anything. The logic is supposed to be that instead of calling update_school_career() no matter what, it only gets called if the "from_age_up" value passed to verify_school is "true." Which should, in theory, mean that update_school_career() won't get called if it's the code in sim.py that is doing the check, thereby negating the "on load" part.
But it's not doing any such thing that I can tell.
But someone pointed out to me a glaring flaw in this, that without having school pushed on you when you age up, unplayed sims would simply never join it or go there, unless you switched to them and joined manually.
This was a good reason, I felt, to try to revisit separating the two, so that it's only loading where the game no longer pushes school on you and aging up still does.
I tried some different approaches last night, searched files, studied the code, but the logic simply didn't make sense.
The code for the Verify_School method is as follows (from sim_info.py):
def verify_school(self, from_age_up):
if from_age_up or self._time_sim_was_saved is None:
if self.is_child:
self.create_homework(self.CHILD_HOMEWORK)
elif self.is_teen:
self.create_homework(self.TEEN_HOMEWORK)
self.update_school_career()
Then in sim.py, there's this:
if self._simulation_state == SimulationState.INITIALIZING:
self.sim_info.verify_school(from_age_up=False)
And in aging_mixin.py, in the advance_age method, there's this:
if next_age > Age.TODDLER:
self.verify_school(from_age_up=True)
These are the only two places, a search shows, where the verify_school method is called. And the method that verify_school calls ("update_school_career()") is only called within sim_info.py
It appears fairly intuitive to me. The call in aging_mixin checks if the sim is aging up to something past Toddler. If they are, verify_school is called. Verify_school checks if the sim in question is a child or teen and generates their little homework booklet if they are. At the end, it calls update_school_career no matter what, which calls this:
self.ensure_age_based_career(Age.CHILD, SimInfo.SCHOOL_CAREER)
self.ensure_age_based_career(Age.TEEN, SimInfo.HIGH_SCHOOL_CAREER)
To verify that their age is Child or Teen and pass along the appropriate school career to be added to them.
The part where my understanding breaks down is this:
1) I can't seem to figure out what "self._time_sim_was_saved is None" actually means and how it relates to the code in sim.py. I'm guessing it relates to it for some reason.
2) It appears that the code in sim.py is passing along the value to verify_school "from_age_up=false" (because it's not from aging up, it's from loading) and the code in aging_mixin.py is passing along the value to verify_school "from_age_up=true" (because it is from aging up).
And yet, if I change the verify_school method to something like this:
def my_verify_school(original, self, from_age_up):
if from_age_up or self._time_sim_was_saved is None:
if self.is_child:
self.create_homework(self.CHILD_HOMEWORK)
elif self.is_teen:
self.create_homework(self.TEEN_HOMEWORK)
if from_age_up:
self.update_school_career()
original(self, from_age_up)
It doesn't appear to do anything. The logic is supposed to be that instead of calling update_school_career() no matter what, it only gets called if the "from_age_up" value passed to verify_school is "true." Which should, in theory, mean that update_school_career() won't get called if it's the code in sim.py that is doing the check, thereby negating the "on load" part.
But it's not doing any such thing that I can tell.