Curious was it hard to figure out and execute? Seems like it would be.
It took a little effort but by process of elimination I finally discovered the issue. As you noticed, the problem was that in some cases the squeaks were not turning on when the vehicle reached the minimum speed.
The simple way of turning on the squeaks would be something like this:
IF vehicle speed > minimum speed
THEN turn on squeaks
This would work but is not what I had done, because it would turn on the squeaks every single time through the main loop as long as the speed exceeded the minimum. That doesn't hurt anything but it's unnecessary work since once the squeaks are on we don't need to turn them on again, unless we later drop below the minimum speed. I try to avoid this kind of activity because even though in this single case it doesn't really take much time, if I have hundreds of things that run like that it all ads up and we take time away from other tasks.
Instead what I had originally was something like this:
IF squeaks = off
AND IF vehicle speed > minimum speed
AND IF prior speed < minimum speed
THEN turn on squeaks
This is a better approach because we only turn on the squeaks once when we need to, the rest of the time we skip this step. (There was a similar command in reverse for turning off the squeaks.)
The problem was that sometimes the prior speed was not getting updated correctly, or anyway, unusual states could be created when changing between forward and reverse quickly, for complicated reasons. The prior speed is only used in a few situations and back when I included it I didn't think through every situation since it was only important at certain times, and I made sure it worked at those times. Later I added the squeaks and just assumed I could always count on them to behave as I wanted for this purpose too. Most of the time that assumption
was correct, which is why I never noticed a problem, but you found the case where it wasn't.
This is a very typical example of the kinds of issues that arise over time when new features are added. With 30,000 lines of code I can't remember everything so I often make assumptions about what ancient Luke did in the past. However that assumes ancient Luke was as smart as present Luke, or that ancient Luke thought ahead to what present Luke might wish he had done in the past, and that usually ends badly.
