About a Patch or file that will replace words in the main script.rpy

DoctorPervic

Well-Known Member
Game Developer
Aug 13, 2019
1,075
4,423
HI, I'm gong to be creating a Visual Novel but before I do I wanted to get some information about Patches if possible. The easiest way possible as I am a complete Noob at Renpy, just started using it a few weeks ago, so dont know much. I know a bit of HTML and CSS but not Python.

So I wanted to know if anyone can explain to me a simple way to create a patch file that when placed into the game folder would overwrite the dialog in the main script.rpy file, as that is where the main dialog will be.

Mainly I will be writing my game with incest content, but would like to make it no incest for displaying on other sites, like patron. so sister or sis would become roommate or girlfriend

However I would like to do it in a way that keeps the feeling in the dialog, When I write the story out, using names like my sister or my mom is important to keep the feeling in the story.

any help is greatly appreciated. thanks so much
 

bas

retired
Donor
Respected User
Former Staff
May 6, 2017
3,987
30,415
The patch file is really simple - just sets a variable like "special" to True where the default is false.

Code:
init 200 python:
    special = True
Code:
guy "I want to fuck you"

if special:
girl "OMG! We can't do that, you're my brother!"
else:
girl "OMG! We can't do that, you're my best friend!"
My lines, btw - don't go stealing my solid gold dialogue.

Code:
if special:
is the same as
Code:
if special = True:
and is shorter

more examples:
Code:
if special:
p "{i}(Damn it has been so long. Should I just call her mom, or use her name?)"
else:
p "{i}(Should I just call her Mrs. Smith, or use her first name?)"

if special:
$ m_name = renpy.input("What is your mom's name? Leave blank for {i}Mom.")
else:
$ m_name = renpy.input("What is her name? Leave blank for {i}Mrs. Smith")
 

DoctorPervic

Well-Known Member
Game Developer
Aug 13, 2019
1,075
4,423
ok thanks, thats cool. One question though. and sorry, but I am very Green in this. :p What code do I put where? What code do I put in my scripts file and what code do I put in my patch file?

Just would like to try it out and see if I have success.
 
Last edited:

bas

retired
Donor
Respected User
Former Staff
May 6, 2017
3,987
30,415
ok thanks, thats cool. One question though. and sorry, but I am very Green in this. :p What code do I put where? What code do I put in my scripts file and what code do I put in my patch file?

Just would like to try it out and see if I have success.
The very first "code" thing in my post above goes in your patch file - you can call it patch.rpy, and everything else in script.rpy.
 

DoctorPervic

Well-Known Member
Game Developer
Aug 13, 2019
1,075
4,423
So this is what I did and if you could let me know if I am dong anything correct. that would be great.

So I created a file called patch.rpy and saved it in the game folder. with the code
init 200 python:
special = True

___________________________________________________________

next I opened up my script.rpy file and included this code inside it.


define e = Character("Julie")
define f = Character("Sara")



label start:


scene bg room


show eileen happy



e "I want to fuck you"
if special:
f "OMG! We can't do that, you're my brother!"
else:
f "OMG! We can't do that, you're my best friend!"

# This ends the game.

return

___________________________________________________________

Just using your solid gold dialogue as a test mind you. :D

___________________________________________________________

Unfortunately I get these errors. what am I doing wrong.

"game/script.rpy", line 17: if statement expects a non-empty block.
if special:

"game/script.rpy", line 19: expected statement.
else:

"game/script.rpy", line 24: Line is indented, but the preceding say statement statement does not expect a block. Please check this line's indentation.
return
___________________________________________________________

Any help is greatly apriciated. Once I understand why it is asking these things, I will be able to get things moving I think. :)
 

scrumbles

Engaged Member
Jan 12, 2019
2,340
2,428
You must indent the statements. That is, you must insert four spaces before "f "OMG! ..."
 
  • Like
Reactions: bas

DoctorPervic

Well-Known Member
Game Developer
Aug 13, 2019
1,075
4,423
That was silly easy. it makes me look really stupid. :p

thank you very much for your help. I'll learn a lot.
 

scrumbles

Engaged Member
Jan 12, 2019
2,340
2,428
It isn't silly at all, don't worry. In most languages blocks are included into curly brackets. Python and Ren'py and an exception, they use spaces. Just pay attention and don't mix spaces and tab characters.
Some text editors automatically indent the code, if you select Python as language: you may ask in Tools and Tutorials what the best software is.

You may avoid to duplicate some lines of your dialogue with a trick like this.
First you set the roles. Something like:
Code:
init 201 python:
    b_role = "brother" if special else "roommate"
    s_role = "sister" if special else "roommate"
    m_role = "mom" if special else "landlady"
(the 201 makes the code to be executed after special is set to true).

Then you use the variables both in the character definition (this is adapted from another game):
Code:
define m = Character("m_role", color="#EFC6E1", dynamic=True)
define s = Character("s_role", color="#D72483", dynamic=True)
define b = Character("b_role", color="#FD3E81", dynamic=True)
and in the dialogue (variables must be put into square brackets):
Code:
f "OMG! We can't do that, you're my [b_role]!"
Pretty sure my code is buggy and doesn't work. But you got the idea.
 

scrumbles

Engaged Member
Jan 12, 2019
2,340
2,428
The attached file is a modded version of The Question, the VN shipped with Ren'py SDK.
If you set special to True in the patch, Sylvie is renamed Belle.
To test it, unzip the files into RENPY_SDK_FOLDER\the_question\game (backup the original files) and launch the game.

To compare the original and the modded file, you may use WinMerge. Most text editors can do it too, but they usually need an additional plugin.

Edit: I fixed the zip. "special" was not defined in the script and the game crashed without the patch.
 
Last edited:

DoctorPervic

Well-Known Member
Game Developer
Aug 13, 2019
1,075
4,423
What would be your choice of editing software? I'm using jedit right now.

Also can I have multiple characters in a single string. for example.

define s = Character("sister_name", color="#c8ffc8", dynamic=True)
define si = Character("sis_name", color="#c8ffc8", dynamic=True)
define sl = Character("slut_name", color="#c8ffc8", dynamic=True)

but all in one line of code? or should I just use the three lines like this,


So it would like like this?

init 201 python:
sister_name = "Belle" if special else "Sister"
sis_name = "Belle" if special else "Sis"
slut_name = "Belle" if special else "Slut"
define s = Character("sister_name", color="#c8ffc8", dynamic=True)
define si = Character("sis_name", color="#c8ffc8", dynamic=True)
define sl = Character("slut_name", color="#c8ffc8", dynamic=True)
define m = Character("Me", color="#c8c8ff")

Or can I make it shorter?
 
Last edited:

scrumbles

Engaged Member
Jan 12, 2019
2,340
2,428
My choice? Sorry, I'm not a Ren'py developer. I use a few light editors but I'm not sure they are suited to work with Ren'py.

Many people like Atom and Sublime Text (a Ren'py plugin is available for both software iirc). Notepad++ is also appreciated here (I like it too). Try all of them and see which editor you are more at ease with.

Just avoid MS Office / Libre Office etc, because they will mess up your code. The only good Microsoft editor is Visual Studio Code.

bas?
 

DoctorPervic

Well-Known Member
Game Developer
Aug 13, 2019
1,075
4,423
Can i use brackets with these?

define s = Character("sister_name", color="#c8ffc8", dynamic=True)
define si = Character("sis_name", color="#c8ffc8", dynamic=True)
define sl = Character("slut_name", color="#c8ffc8", dynamic=True)

Because I am thinking if I have a name labeled a. and then I use a in a sentence it could get messy, because sometimes i would be using the word a as a name and other times use it to make a sentence.

thanks for the editor choices. i'll check them out.
 

scrumbles

Engaged Member
Jan 12, 2019
2,340
2,428
Sorry, I'm not sure I understand. But if "a" is not between brackets inside a sentence, it is not replaced by the engine. It's just a plain string. Ren'py treats as a variable only what you put between [...].
As for Characters, they don't need brackets.
For instance:
Code:
init 201 python:
    a_role = "aunt" if special else "neighbour"
    ...

define a = Character("a_role", color="#c8ffc8", dynamic=True)
...
    a "Hi, Max. Don't you give a hug to your [a_role]?"
will return:
Aunt
Hi, Max. Don't you give a hug to your aunt?
Btw, I fixed the script in the .zip (I added the definition of "special" at the beginning of script .rpy).
___________________________________________________________________________

Instead of defining multiple Characters that differ only in a string, you can create a dictionary of names. Like that (I'm using The Question again):
Code:
init 201 python:
    sylvie_name = {"normal":"Belle", "love":"Sweetheart", "short":"Be", "degr":"Slut"} if special else  {"normal":"Sylvie", "love":"Sweetheart", "short":"Syl", "degr":"Slut"}
Now when you call Belle/Sylvie, you can just append the right prefix: normal for Belle/Sylvie, love for Sweetheart and so on.
Code:
    define s = Character("sylvie_name['normal']", color="#c8ffc8", dynamic=True)
    "I've known [sylvie_name[short]] since we were kids. She's got a big heart and she's always been a good friend to me."
A more advanced solution is to create a special function that returns Sylvie's name, depending on her stats (for instance her love-meter).
 
Last edited:

DoctorPervic

Well-Known Member
Game Developer
Aug 13, 2019
1,075
4,423
thank you so very much for all your help. Greatly appreciated. Great link about editors. I'm checking out Atom and Sublime