Ren'Py Changing names on prenamed mc.

xDEEPx

Active Member
Oct 7, 2017
550
167
So in some Ren'Py games you already have a pre-named main character that you arnt given the option to rename... is their a loop around or something I can to change it to my own preference?
Not sure if this is in the right section..
ty <3
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,607
2,256
If you're talking about your own game... it sounds like you want something like this:

Python:
default player_name = "Unnamed"

define mc = Character("[player_name]")

label start:

    scene black with fade

    $ player_name = renpy.input("What is your name? {i}(Just press ENTER for 'Steve'){/i}", )
    $ player_name = player_name.strip() or "Steve"

    mc "My name is [mc]"

    "*** THE END ***"

    return
You'll see lots of variations on this in various game.

The player_name.strip() is to remove spaces on the beginning or end of names.
The or "Steve" is just shorthand. If [player_name] is blank, it'll use "Steve" instead.

You'll see lots of games that will do $ mc = renpy.input()... it's stupid. You're effectively throwing away the Character() object with all it's attributes and replacing it with just a String() object. No colors, no outline colors, etc. It's just a bit of simple code that lots of people have been copy-pasting without knowing any better for years.

You could do mc "My name is [player_name]" too. Using the mc Character() object instead is a slightly better habit, since it means you can do it with other character names too... which is a good habit which leaves things open for changing other character names too in addition to the mc.

It you want the completely over the top version... see my other post...
https://f95zone.to/threads/suggestion-code-for-multi-game-persistent-character-names.55475/
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,607
2,256
If you really are talking about other people's games, and those games didn't give you the choice to change the mc's name... then you have two options...

"No".

Okay... That's the simple answer. The author didn't think to allow you to change the character's name and therefore the code probably doesn't even come close to working that way.


"Maybe".

This one would require some work and a bit of understanding of the way RenPy games are coded.

Most games are compressed to use RenPy Archive files (.rpa files). You can unpack them using tools like UnRen. (Grab the current 0.9 alpha version, as 0.8 won't unpack some more recent games).

Once unpacked, you should be able to edit the source code. If the .rpy files still aren't there, you can use UnRen again to convert the .rpyc files back into .rpy files.

Let's assume the standard name is "Steve" and you want to use "Xander"...
A simple edit would be to use a text editor (RenPy uses version as it's recommended editor) to change all the places where it says "Steve" to "Xander". (Editors as good as Atom will let you do "Change all" across multiple files at the same time... less complex editors might mean you need to edit each .rpy file separately).

Except... because the game wasn't written that way... you might cause some unintended changes. Like maybe there are a series of pictures like steves_house.png or steve_sitting.png. You could avoid changing them on accident by not using "Change All...", but it'll be a lot of wasted time checking things line by line. My suggestion is that if you go this route, do the "Change All..." and then fix anything that breaks as you go along.

You could of course change all the references of "Steve" to "[mc]" and add the code I wrote in the first post. But it that seems like it might be hard work for you... then don't.
 
  • Like
Reactions: xDEEPx

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,957
16,188
Let's assume the standard name is "Steve" and you want to use "Xander"...
A simple edit would be to use a text editor [...]
Or, to avoid the many issues you talked about, there's the possibility to do it in the fly :
Code:
init python:

    def myNameChange(text):
        return renpy.re.sub( r'\b{}\b'.format( MODmcName ), MODwantedName, text )

    config.say_menu_text_filter = myNameChange

default MODmcName = "Steve"
default MODwantedName = "Xander"
But it will still need to change the name in the Character object.
 

xDEEPx

Active Member
Oct 7, 2017
550
167
If you really are talking about other people's games, and those games didn't give you the choice to change the mc's name... then you have two options...

"No".

Okay... That's the simple answer. The author didn't think to allow you to change the character's name and therefore the code probably doesn't even come close to working that way.


"Maybe".

This one would require some work and a bit of understanding of the way RenPy games are coded.

Most games are compressed to use RenPy Archive files (.rpa files). You can unpack them using tools like UnRen. (Grab the current 0.9 alpha version, as 0.8 won't unpack some more recent games).

Once unpacked, you should be able to edit the source code. If the .rpy files still aren't there, you can use UnRen again to convert the .rpyc files back into .rpy files.

Let's assume the standard name is "Steve" and you want to use "Xander"...
A simple edit would be to use a text editor (RenPy uses version as it's recommended editor) to change all the places where it says "Steve" to "Xander". (Editors as good as Atom will let you do "Change all" across multiple files at the same time... less complex editors might mean you need to edit each .rpy file separately).

Except... because the game wasn't written that way... you might cause some unintended changes. Like maybe there are a series of pictures like steves_house.png or steve_sitting.png. You could avoid changing them on accident by not using "Change All...", but it'll be a lot of wasted time checking things line by line. My suggestion is that if you go this route, do the "Change All..." and then fix anything that breaks as you go along.

You could of course change all the references of "Steve" to "[mc]" and add the code I wrote in the first post. But it that seems like it might be hard work for you... then don't.
If you're talking about your own game... it sounds like you want something like this:

Python:
default player_name = "Unnamed"

define mc = Character("[player_name]")

label start:

    scene black with fade

    $ player_name = renpy.input("What is your name? {i}(Just press ENTER for 'Steve'){/i}", )
    $ player_name = player_name.strip() or "Steve"

    mc "My name is [mc]"

    "*** THE END ***"

    return
You'll see lots of variations on this in various game.

The player_name.strip() is to remove spaces on the beginning or end of names.
The or "Steve" is just shorthand. If [player_name] is blank, it'll use "Steve" instead.

You'll see lots of games that will do $ mc = renpy.input()... it's stupid. You're effectively throwing away the Character() object with all it's attributes and replacing it with just a String() object. No colors, no outline colors, etc. It's just a bit of simple code that lots of people have been copy-pasting without knowing any better for years.

You could do mc "My name is [player_name]" too. Using the mc Character() object instead is a slightly better habit, since it means you can do it with other character names too... which is a good habit which leaves things open for changing other character names too in addition to the mc.

It you want the completely over the top version... see my other post...
https://f95zone.to/threads/suggestion-code-for-multi-game-persistent-character-names.55475/
That was some lovely devotion to precise explanation.. ty.
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,607
2,256
Python:
init python:

    def myNameChange(text):
        return renpy.re.sub( r'\b{}\b'.format( MODmcName ), MODwantedName, text )

    config.say_menu_text_filter = myNameChange

default MODmcName = "Steve"
default MODwantedName = "Xander"
Ah. Yeah... That's a much better option than my "Maybe" answer.

That was some lovely devotion to precise explanation.. ty.
Honestly, I wrote the first reply... then re-read your first post and realized you probably were talking about other people's games. Rather than delete it, I figured I'd just do a quick edit and leave both there to cover all the bases.
 
  • Like
Reactions: xDEEPx

vcmhome

New Member
Apr 29, 2020
11
14
I'm midway through a game, and had to load another person's save. as a result my MC's name changed from "Vinnie" to "You".
Is there a way for me to change the name back to Vinnie? surely this could be done using console??
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,957
16,188
I'm midway through a game, and had to load another person's save. as a result my MC's name changed from "Vinnie" to "You".
Is there a way for me to change the name back to Vinnie? surely this could be done using console??
The game clearly let name your MC, so yes there's a way to do this. But it all depend of the game, so ask in the game thread, it's where you'll be the more likely to have an answer.
 
  • Like
Reactions: vcmhome

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,607
2,256
I'm midway through a game, and had to load another person's save. as a result my MC's name changed from "Vinnie" to "You".
Is there a way for me to change the name back to Vinnie? surely this could be done using console??
Most likely, yes.
But it depends on the game.

You could use a tool like the savefile editor here.
Or a website like that does similar things online. (edit: website didn't work for me - or at least didn't show string values).

Alternatively, as long as you have the developer mode/console mode enabled, you can use the console to do it...

Start the game with dev+console enabled.​
Load your saved game.​
Press [shift+D] to open the developer menu.​
- Select the Variable Viewer.​
Find the variable that you can recognize as the player's name (it's value will be "You").​
Make a note of the name of that variable.​
Return to the developer menu.​
Press [shift+O] to open the console.​
Type {name of variable}="Vinnie" and press <ENTER>. (Without the silly brackets, pc_name="Vinnie" for example).
Press <ESC> to return to the game with your new name.​
Save.​
 
Last edited:

vcmhome

New Member
Apr 29, 2020
11
14
Most likely, yes.
But it depends on the game.

You could use a tool like the savefile editor here.
Or a website like that does similar things online. (edit: website didn't work for me - or at least didn't show string values).

Alternatively, as long as you have the developer mode/console mode enabled, you can use the console to do it...

Start the game with dev+console enabled.​
Load your saved game.​
Press [shift+D] to open the developer menu.​
- Select the Variable Viewer.​
Find the variable that you can recognize as the player's name (it's value will be "You").​
Make a note of the name of that variable.​
Return to the developer menu.​
Press [shift+O] to open the console.​
Type {name of variable}="Vinnie" and press <ENTER>. (Without the silly brackets, pc_name="Vinnie" for example).
Press <ESC> to return to the game with your new name.​
Save.​
Thanks !!
Savefile editor worked a treat !