If you're playing the game and you'd like to make this change within the context of your current play, the best way is to open up the developer console and just executeI have a ren'py game with code like this:
How does one create a patch to change "teacher" to "gardener"?Code:$ personTitle = "teacher"
personTitle = "teacher"
config.console = True
RPYC files are not generally encrypted. They are compiled versions of the original RPY files. There are a number of different tools available that will "decompile" the RPYC files into equivalent RPY files. One such isRPYC files are encrypted.
label after_load:
try:
if personTitle is "teacher":
personTitle = gardener
except:
pass
return
$ personTitle = "teacher"
init:
define personTitleType = "teacher"
$ personTitle = personTitleType
init 10:
define personTitleType = "gardener"
$ personTitle = personTitleType
init python:
try: NewVariableName
except NameError: NewVariableName = None
if NewVariableName == None
"When this happened yesterday, what did you do?"
menu:
"I did option 1":
$ NewVariableName = 1
"I did option 2":
$ NewVariableName = 2
Sorry, but you got a "nasty message" because you do nasty things ; you don't need to rely on exceptions here. The none nasty way is :Code:init python: try: NewVariableName except NameError: NewVariableName = None
init python:
if not "varName" in globals():
varName = None
init python:
if not hasattr( store, "NewVariableName" ):
NewVariableName = None
Except that I'm NOT getting a nasty message when I use the code to 'cover' for added variables that aren't defined in previous saves. Try it and get back with me, you'll see that it works. I've used this in two separate published mods now, without issue.Sorry, but you got a "nasty message" because you do nasty things ; you don't need to rely on exceptions here. The none nasty way is :
Which will works great since Ren'py import the whole default store as global for every Python block or singleton line. But like every variable is in fact an attribute of the store object, it's more clean to do it like this :Code:init python: if not "varName" in globals(): varName = None
Then, like said in theCode:init python: if not hasattr( store, "NewVariableName" ): NewVariableName = None
You must be registered to see the linkshow-to (second part of A-4), if you replace the direct assignation by the use of setattr, it even offer you a way to automatize this availability control, including assignation of the effective default value, with just three lines in the after_load label (that you write then forget), plus one line for each update.
It's not because you intercepted it with the except clause, before it reach the exception handler of Ren'py, that you didn't get the nasty message. You don't see it, which is not the same thing than not having it.Except that I'm NOT getting a nasty message [...]
I didn't said that it wasn't working, just that you don't need to rely on an exception when there's a built-in function wrote especially to do what you want to do.Try it and get back with me, you'll see that it works.
Reason why I wrote the how-to I linked above. I have the knowledge, they have the problem... and after reading it, they share this part of my knowledge and don't have the problem anymore.but developers add variables to new versions all the time, and then expect people to replay the entire game, rather than 'covering' for their lack of foresight.
Let me phrase it otherwise: If you wear a 50cm layer of foam all around you, you don't care if a car hit you when you cross a road. Yet, it doesn't mean that it's not easier and better to just look both side before crossing the said road.My way DOES work, you are just citing other ways to do the same thing.
And so ? Between your answer and mine, they now have three different ways to resolve this issue... You should be happy, not angry.The entire point here is to help help developers find ways to resolve such issues, as this has been an ongoing problem.
Apparently I really didn't expressed my thoughts clearly enough. Despite the, probably unavoidable, paradigm bias between "Interestingly enough, the "do an explicit 'if' test" versus "catch an exception" debate also splits the modern Python world.[...]
Suffice it to say that both approaches are completely valid.[...]
for varName in [ "newVar1", "newVar2", "newVar3", ... ]:
if hasattr( store, varName ) is False:
setattr( store, varName, False )
As proof that it's negligible effect, Ren'py itself use more than ten exceptions to control its own process. jump and call are, beyond other things, performed by the raise of an exception.And with modern Python (and modern machines) the difference is negligible unless you were somehow doing this a LOT, which isn't the case in a Ren'py game.
Hey, this is the "Programming & Development" forum on F95, after all... LOLA programming discussion on a forum for adult games
With a background in C, you've probably seen (or heard about) the flame wars about where braces should go. Every language has its schisms... LOLI didn't know people held strong preferences over using if or exceptions, lol.
Well, I guess it was to be expected since the only thing I'm decent at is some C.
You're absolutely right. And were programmers not lazy thus using default automatic indentation in IDEs we'd still be probably discussing the one true way to indent code, lol.Hey, this is the "Programming & Development" forum on F95, after all... LOL
With a background in C, you've probably seen (or heard about) the flame wars about where braces should go. Every language has its schisms... LOL
This is just a guess (more like a wild-ass guess), but some of that may have come from preconceived biases of people rooted in other languages where exceptions are a lot more expensive, and thus rarely used. I think they're much lighter-weight in Python than in Java or C#, for example, and MUCH lighter-weight than in C++. So to "native Pythoners," their common use may be less the, um, exception than the rule. (Sorry - I just couldn't resist! XD)
So now the debate has just shifted to "what should be the settings for the automatic indentor in the IDE.You're absolutely right. And were programmers not lazy thus using default automatic indentation in IDEs we'd still be probably discussing the one true way to indent code, lol.
At least this was a decision I understood, as it removed any of the problems of ambiguity as to "how many spaces equal a tab" if you had a file with mixed "tab indenting" and "space indenting," which would definitely have happened.Another reason why I won't ever get into python: this tab discrimination in 2018 is not acceptable! =P
For this stuff I usually run Notepad++ and I could set it to use whitespaces instead of tabs, but I don't know if I can for specific file extensions only. I surely don't want that in general.So now the debate has just shifted to "what should be the settings for the automatic indentor in the IDE.
At least this was a decision I understood, as it removed any of the problems of ambiguity as to "how many spaces equal a tab" if you had a file with mixed "tab indenting" and "space indenting," which would definitely have happened.
If you use an editor that "understands" Python, you can hit the tab and shift-tab key and it spaces and un-spaces for you. (Atom is very good at that.)
Not even talking about older people and their, "exceptions ? You mean like when the program crash and you need to pass a whole week finding which 'if' you need to add to prevent it ?"This is just a guess (more like a wild-ass guess), but some of that may have come from preconceived biases of people rooted in other languages where exceptions are a lot more expensive, and thus rarely used.
Not sure that there's a language where they are as much light-weighted than in Python. I mean, Python internally use an exception to tell itself that it have reached the end of an iteration, or to warn "hasattr" and "getattr" that there's no attribute with the given name. And in Python, both iterations and these two built-in functions are massively used...I think they're much lighter-weight in Python than in Java or C#, for example, and MUCH lighter-weight than in C++.