OH! That's perfect!I think you can use the after_load label for that -You must be registered to see the links
label after_load:
to "fix" stuff (like the values of variables) they screwed up in a previous release of the game. ep2_saw_mom_in_shower
wasn't set correctly during episode 2, so you're correcting it in ep3... But HOW you correct it matters, since that "fix" is still going to be run for not only those broken save files, but perfectly fine save files for ep8, 11 and onward. Not only that, it's also going to be run for players just (re-)starting the game during ep1.I'm using it to make some sort of "computed property".Just keep in mind that label will be called EVERY time a save file is loaded.
It's very easy to forget that whatever you do there will continue to be executed long, long into the future.
People tend to uselabel after_load:
to "fix" stuff (like the values of variables) they screwed up in a previous release of the game.
Maybeep2_saw_mom_in_shower
wasn't set correctly during episode 2, so you're correcting it in ep3... But HOW you correct it matters, since that "fix" is still going to be run for not only those broken save files, but perfectly fine save files for ep8, 11 and onward. Not only that, it's also going to be run for players just (re-)starting the game during ep1.
Maybe you're doing something else, so it's not an issue.
All I'm saying is think through all the various combinations - or it'll come back to bite you in the ass.
if professor_saw_caseys_porn_site:
professor "Casey, blablsbla porn site, blabla"
if casey_refused_to_run_naked_at_first:
professor "Casey, blablsbla porn site, blabla"
I don't think this will cause problems to me in the future. Will it?
I'm doing this just for the sake of increasing readability of my code base.
after_load:
?call calculate_derivative_variables
. Either at some key point in the code (a sort of central hub or hubs) or after you've updated any variable which could contribute toward your derived variables.after_load
.after_load
is necessary, it's because the values of the derived variables are not in line with their contributing variables - presumably because you're not calling calculate_derivative_variables
often enough. Either that, or the variables are all fine and you're doing the whole label after_load:
for no reason.after_load
is needed.Is this a bad practice?
I only call it on loads. I don't need to refresh them any other time.No clue. It looks safe enough. But then, how could I tell.
Yeah. I can see you're aiming to simplify your variables.
My question would be why you would need to refresh them usingafter_load:
?
I presume (always a bad idea) you regularlycall calculate_derivative_variables
. Either at some key point in the code (a sort of central hub or hubs) or after you've updated any variable which could contribute toward your derived variables.
Therefore the derived variables will always be up to date.
But if they're already up to date, then there's no need to update them duringafter_load
.
Therefore, ifafter_load
is necessary, it's because the values of the derived variables are not in line with their contributing variables - presumably because you're not callingcalculate_derivative_variables
often enough. Either that, or the variables are all fine and you're doing the wholelabel after_load:
for no reason.
Or put another way... Would your game still work if a player never loaded a save file... Just played from beginning to end in one session, without ever quitting the game? Because if the answer is yes, I'm not sure why theafter_load
is needed.
At best, we could say it's doing no harm. Just setting values that were already set correctly anyway.
At worst, it could be masking a more fundamental underlying problem.
Pardon my skepticism, I'm just being cautious.
If it works... it's fine.
Seriously, RenPy is as simple or complex as you want it to be.
There will always be people who say something can be done better or refined or whatever... but if it works... it's fine.
What matters more is that YOU understand your own code.
If you were part of a team, it might matter... since you'd all need to be on the same page. But a one-man project... whatever works for you.
So far it's just bool assignation, so yes, it's safe.I don't think this will cause problems to me in the future. Will it?
Readability isn't the only thing you should take in count, you code should also be easy to write, and I have some doubts due to the really big size of your flags' name.I'm doing this just for the sake of increasing readability of my code base.
student_list_received_caseys_trail_nudes_with_no_face
is easier to understand don't make doubt.
if students_list_received_caseys_nudes:
[...]
That's a fair point, but I usually rely on the IDE's intellisense to autocomplete my typing.So far it's just bool assignation, so yes, it's safe.
You don't effectively change a value, but compute it according for formulas that are frozen in time. What mean that the result of the said computation will also be frozen.
Readability isn't the only thing you should take in count, you code should also be easy to write, and I have some doubts due to the really big size of your flags' name.
It doesn't meant that I'm right to have doubts, it can be perfect for you since here it depend solely of your own abilities. But I know from experience that the longer and more explicit are the variable name, the more people tend to in fact forget them and/or make typo when writing them. Especially when there's in the end so many that are just aliases of a base flag.
That something likestudent_list_received_caseys_trail_nudes_with_no_face
is easier to understand don't make doubt.
But if, in few months, you'll need to use it again, will your remember that it's the "student_list" and not the "students_list" ? Will you remember that it's the "trail_nudes" and not just the "nudes" ? Will you remember that you specified that they were "with_no_face" and not that it was implied ?
Because if your efforts to increase the readability lead you to write
if students_list_received_caseys_nudes:
[...]
then it will have in fact just broke your game.
And if it imply that, each time you need to write a flag name, you've first to pass through the list of flags' name in order to validate that you write it correctly, then it will make you lost times and make the writing of your code feel a little more like a burden.
But, as I said above, this are just my doubts. I'm not you, therefore perhaps that for you all this is effectively really explicit, and also really easy to remember and to use. And if it's the case, they I've nothing to say, go with it.