So it all works. But....
[...]
Why cant I change the color?
The issue is because you're initially creating a
Character()
and then overwriting it with a string object. String objects have none of the parameters/properties necessary for the formatting your want.
So you start off with
define ThePlayer = Character()
. That's fine.
But later, you do
$ ThePlayer = renpy.input()
.
renpy.input()
returns a string. So now
ThePlayer
is now a string and not a
Character()
.
What you need to do is separate the character object from the variable that contains the name.
Using your own code as the basis...
Edit: This code is a good example for other people, but won't solve YOUR problem. I've written something specific to your project further down...
Python:
define ThePlayer = Character("[player_name]", what_font="Chianti Bold Win95BT.ttf", color="#323ee3")
define ThePlayer_t = Character("[player_name]", what_font="Chianti Bold Win95BT.ttf", color="#323ee3", what_prefix="{i}(", what_suffix="){/i}", who_prefix="{i}", who_suffix="{/i}")
default player_name = "Unnamed"
label start:
scene black with fade
$ player_name = renpy.input(_("What's your name?... {i} (Press ENTER for 'Jonas' or type in your choice.) {/i}"))
$ player_name = player_name.strip()
if not player_name :
$ player_name = "Jonas"
"Hello [ThePlayer]."
return
I've tweaked your "character thinking" definition a bit, to make the text shown when thinking italic and also wrap it in parenthesis (pretty normal for VNs).
Now, the new variable
player_name
stores the name of the main character and the two
Character()
objects use string substitution to use that variable whenever it's displayed.
Now the problem...
You're going to have to delete all your current save files.
Oh crap. You've already released version 0.0.15.2 of your game... Downloading now to check it.
While it downloads, let me just explain the problem...
Any saves files out there have a variable called
ThePlayer
in them. That variable, in that version of the game, is a string. When you load the save file, whatever you've got coded will be overwritten with the variable stored in the save file. Essentially, it'll reset your
Character()
object - as I've described above.
I can only see one reasonable answer, but I'm not sure you're going to like it.
Let me also adapt my answer to include your need for a German translation...
Python:
define mc = Character("[ThePlayer]", what_font="Chianti Bold Win95BT.ttf", color="#323ee3")
define mc_t = Character("[ThePlayer]", what_font="Chianti Bold Win95BT.ttf", color="#323ee3", what_prefix="{i}(", what_suffix="){/i}", who_prefix="{i}", who_suffix="{/i}")
default ThePlayer = "Unnamed"
label start:
scene black with fade
$ ThePlayer = renpy.input(_("What's your name?... {i} (Press ENTER for 'Jonas' or type in your choice.) {/i}"))
$ ThePlayer = ThePlayer.strip()
if not ThePlayer :
$ ThePlayer = _("Jonas")
"Hello [mc]."
return
Then go into your script editor and do a "Change ALL 'ThePlayer' to 'mc'."
If you're using Atom, you would...
- Press <CTRL+SHIFT+F> (Find and Replace in all files).
- Change "Find in Project" to
ThePlayer
- Change "Replace in Project" to
mc
- Change "File/Directory Pattern" to
*.rpy
- Activate the button on the right side with
Aa
in it, to make the search/replace case sensitive.
- Click
[Replace All]
Next you're going to need to fix the couple of places that have been changed to
mc
but still need to say
ThePlayer
.
In my example, that would be the
default
line that initializes the main character name to be "Unnamed". The
Character()
definitions which need the
[mc]
changing to
[ThePlayer]
and the section of code that does the
renpy.input
of the name.
Then you're going to need to get into the habit of typing "mc" instead of "ThePlayer".
Honestly, it can be anything EXCEPT "ThePlayer", since
ThePlayer
is a string variable separate from the
Character()
definition. I've used "mc" because it is the common identifier used in VNs and it's quick to type.
By doing it this way... even though the variable
ThePlayer
was incorrectly used in the original version of the game... it can still be used for future versions without breaking anything. So when a player loads an old save file... everything will still work.
Plan-B: Use the solution I suggested first. Then go into the
options.rpy
file and change the line that start
define config.save_directory =
to something else. That will force future save files to be stored somewhere else and you'll need to tell existing players that old save files are not compatible with the current version.
Of course, this is all just my opinion. Someone else might come up with an alternative solution. But the fact that you've already released a version of your game with this code in it... makes it awkward to fix.