Ren'Py Don't use 'if renpy.loadable("patch.rpy"):' in your games

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,141
14,825
How can I avoid that?
You can't avoid it, just deal with it.

Like you said, the problem come from the change in the label name. The "reference ID" used to design the string isn't the same anymore because of this


is there any way for renpy to notice if the text is the same instead of the label name? (I seem to remember that in the menu options it does, I'm not sure).
There's the translate LANGUAGE strings statement, which is more generic, but I think that it apply only for screens. Anyway it would slow down the game since Ren'py would have to compare the strings instead of just searching for the right label.


Or maybe generate the translation ("tl/english/patch.rpy"), make a copy/paste of the other translation ("tl/english/meg.rpy") and make a substitution of the label "meg_intro" for "meg_intro_p"?
I think this last option would work, but if there's any easier one I'd like to know :p
It should works yes. When looking at the two example you provided, only the part of the reference regarding the label changed, but I don't have looked deep enough to the translation part to ensure that the rest of the reference (the "b472194a" in your example) effectively describe the string and not it's position into the label.


Note: Could it be easier using the new function "config.allow_duplicate_labels"? :unsure:
It all depend of what I said right above.
If the "b472194a" describe the string, then yes it would be easier since the actual translation file would works without problem. But if it describe the position of the string, then the problem would stay the same. The start of the reference would be "meg_intro_" for both, but it's the rest of the reference that would change.


The ideal would be to have a script that use the comment (or old property) to rebuild the translation file.
 

Porcus Dev

Engaged Member
Game Developer
Oct 12, 2017
2,582
4,686
It all depend of what I said right above.
If the "b472194a" describe the string, then yes it would be easier since the actual translation file would works without problem. But if it describe the position of the string, then the problem would stay the same. The start of the reference would be "meg_intro_" for both, but it's the rest of the reference that would change.
Yes, those values (b472194a) appear to be the same in the translation lines generated in both files ("tl/english/meg.rpy and patch.rpy"); I have checked it in 5 lines, and I have added a text in front and I have generated the translation again to make sure that it didn't change... it seems that these numbers should be assigned according to the content of the text, and as it is identical, the numbering as well.

Could you, please, give an example of how to use "config.allow_duplicate_labels"?
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,141
14,825
Could you, please, give an example of how to use "config.allow_duplicate_labels"?
It's the easiest thing ever. You put this :
Code:
python early:
    config.allow_duplicate_labels = True
preferably in the first script (according to the alphabetical order), just to be totally safe.

Then, Ren'py will not complain anymore if a label is redefined. So, you just need to ensure that the labels will be parsed in the right order. This mean that if the original label is in the file "script.rpy", the new label must be in a file that appear later on the alphabetical order.
You also have to take attention if you put it in a rpa file, they are also proceeded by alphabetical order, which mean that "archives.rpa/script.rpy" will normally be proceeded before "patch.rpa/01script.rpy".
 
  • Love
Reactions: Porcus Dev

Porcus Dev

Engaged Member
Game Developer
Oct 12, 2017
2,582
4,686
It's the easiest thing ever. You put this :
Code:
python early:
    config.allow_duplicate_labels = True
preferably in the first script (according to the alphabetical order), just to be totally safe.

Then, Ren'py will not complain anymore if a label is redefined. So, you just need to ensure that the labels will be parsed in the right order. This mean that if the original label is in the file "script.rpy", the new label must be in a file that appear later on the alphabetical order.
You also have to take attention if you put it in a rpa file, they are also proceeded by alphabetical order, which mean that "archives.rpa/script.rpy" will normally be proceeded before "patch.rpa/01script.rpy".
Thank you very much!
I was precisely reading this:
:LOL::LOL::LOL:

Yes, I use "rpa"... then I guess adding the new labels in a file called z_patch or something similar (starting with "z") would be enough for renpy to consider it the "newest" label.

Much appreciated! ;)
Now I just need to download the latest version of renpy and try it :p
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,141
14,825
Yes, I use "rpa"... then I guess adding the new labels in a file called z_patch or something similar (starting with "z") would be enough for renpy to consider it the "newest" label.
It should.


Now I just need to download the latest version of renpy and try it :p
A was published yesterday, right in time :D
 

Porcus Dev

Engaged Member
Game Developer
Oct 12, 2017
2,582
4,686
It should.

A was published yesterday, right in time :D
Well, although it works well in terms of replacing the label, it doesn't do the same with the translation, it appears in Spanish if I don't generate a new translation file ("tl/english/zpatch.rpy"); and if I generate the translation, renpy generates a new identifier, instead of "meg_intro_b472194a", it generates "meg_intro_b472194a_1".

So I think I'm going to choose to use "config.label_overrides", do a copy/paste and rename the label name :p
 

Honey hunters

Member
Jan 23, 2020
118
26
Hello everyone I'm new to developing Ren'Py game, I made a game with incest patch , the incest patch with windows working good but when coming to android version the incest patch was not recognising the game....soo can anyone help me what should I do for android version to recognise the patch.rpy.....

In my game I used
This statements

Python:
#########if statement############
if renpy.loadable("patch.rpy"):


  ########else statement##########  
else:
This patch working fine in windows version and when coming to android version not recognising the patch and going to default code.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,141
14,825
soo can anyone help me what should I do for android version to recognise the patch.rpy.....
[...]
Python:
#########if statement############
if renpy.loadable("patch.rpy"):
Open the APK file with 7Zip, look at it's content, and you should understand what to do.


This said, the whole purpose of this thread was to explain why it's really far to be a good idea to use this method for patching a game. Especially when the patch exist to add content banned on Patreon.
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,559
2,176
This patch working fine in windows version and when coming to android version not recognising the patch and going to default code.
When files are converted for Android, they tend to get renamed to filenames starting "x-......". So chances are, your game is looking for "patch.rpy" and the file is now called "x-patch.rpy". When it doesn't find it, it follows the default game route.

If you can access folders on your phone/tablet - you could try copying the file so the copy matches it's expected name.

Failing that... it's difficult to know exactly what to recommend. If you know how to build your own Android APK, you could perhaps alter the original game's code.

Alternatively, as Anne suggests... you could open the .apk file in 7Zip and ... erm... actually I don't know... I assume rename the patch file back to it's original name and hope your android device doesn't get upset at the new name.
 
  • Like
Reactions: Honey hunters

Rich

Old Fart
Modder
Respected User
Donor
Game Developer
Jun 25, 2017
2,466
6,934
Alternatively, as Anne suggests... you could open the .apk file in 7Zip and ... erm... actually I don't know... I assume rename the patch file back to it's original name and hope your android device doesn't get upset at the new name.
While you can explore inside an APK this way, you usually can't modify the APK this way because the APK is signed as part of producing it, and this would almost always result in the signature being invalid.

This patch working fine in windows version and when coming to android version not recognising the patch and going to default code.
So, describe exactly what you do to apply the patch in the Android version of the game. In the Windows version, you copy the "patch.rpy" file into the "games" directory, I presume. What do you do on Android?