Ren'Py Script helf for Playername

Blackthunder_vn

Active Member
Game Developer
Jan 31, 2020
582
1,467
Yes this is the big big problem. But you will need to start an new Game with 0.0.16.

Yes the old saves have an problem with the new variable (as it is now in 0.0.15.2). I can't change ThePlayer to MC no chance. If I do it I loose an Week or more, just to fix all problems then.

Sorry but i think i must change the colors of "thinks" / "denkt" / "whispers" / "flüstert" if there is no other chance to do it.

My Problem is to understand why:

[ThePlayer] has the renpy color. And RenPy can't take the definition of [ThePlayer] but renpy can take the definition of "the other ThePlayer's" for example

[ThePlayer] *thinks* it is the same definition but it has an "other" Playername (ThePlayer_t_en).

So there must be an possibility that I say renpy the string is the definition of ThePlayer with the other it works why not with ThePlayer single?
 
Last edited:

Blackthunder_vn

Active Member
Game Developer
Jan 31, 2020
582
1,467
79flavors If I change the Line / theplayer "Has an error." / to mc "Has an error." and make the translation it has an other hash.

This means if it has an other hash you need to copy the parts of the translation (line, hash, new english line etc.) to its old place and replace it.

And I must set dte definitions for ThePlayer new 5 pieces.

Just Problems and much of lost time.
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,581
2,219
Yes this is the big big problem. But you will need to start an new Game with 0.0.16.

Yes the old saves have an problem with the new variable (as it is now in 0.0.15.2). I can't change ThePlayer to MC no chance. If I do it I loose an Week or more, just to fix all problems then.

I've written instructions that talk you through changing things in a couple of minutes... not a week.
But yes, if you do it manually... then yeah... it's a lot of work.

Edit: You replied mentioning the hashes. And yes, I'm overlooking the mechanics of the translation again. I'm looking at it now, but I accept it may not be as simple I as I might have hoped.

My Problem is to understand why:

[ThePlayer] has the renpy color. And RenPy can't take the definition of [ThePlayer] but renpy can take the definition of for example

I'm not sure what to say. I think I've explained it in as simple a way as I know how. Perhaps it's a translation issue.

You create a Character(), which supports all the color and customization you want, then erase all that when you use renpy.input(). Because of the save files, that problem means you can't use ThePlayer for anything except a variable that stores the name of the character. The rest is just workaround for those two problems.

I wish you luck in finding a solution you will accept.
 
Last edited:
  • Like
Reactions: LightmanP

Blackthunder_vn

Active Member
Game Developer
Jan 31, 2020
582
1,467
79flavors don't understand me wrong, your way is good. your instruction is good. These are not my Problems.

The instruction is super for the english part, but it changes the hashes, and then I must change every single Line I have changed in the english part manually in the translation part.

And to check all the lines oh my god. 30 hrs just for set the german part in its old form.

Then check for problems missing lines etc. (Playthrough 2 times every version english and german) slow run to check min. 4 hrs.

Do you see where my problem is?

There must be an possibility to say renpy the string is the definition from theplayer.
 
  • Like
Reactions: 79flavors

moskyx

Forum Fanatic
Jun 17, 2019
4,005
12,960
I'm not so sure.
The translation files are also called *.rpy so it might be fine

It's something I'd do myself. But I understand his hesitancy.
No, I mean, if he has this line in the original script: ThePlayer "Ok, fine."
Now it would be: mc "Ok, fine."

And that means that the translation he already has in place for ThePlayer "Ok, fine." won't work due to how Ren'Py handles the translation function (the problem is in the that are actually an encrypted version of the line's content, so if you change anything in that line, including the sayer id, the line's identifier will change and Ren'Py won't find a match when displaying the translation). So he'd need to rewrite every single ThePlayer's line in the translation file, and that's not an easy 'search and replace' in just one step, he'd need to do it line by line. So if he has 7.5k lines... well I don't know if I'd do it either
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,581
2,219
Do you see where my problem is?

Yeah. More so now that I've played with it for an hour or so.

so if you change anything in that line, including the sayer id, the line's identifier will change and Ren'Py won't find a match when displaying the translation).

Yeah. Being an English speaker, I tend to overlook the problems inherent with the RenPy translation issues.

However, it is possible... and without breaking existing saves.
As you both say though, bringing the translations files back into line is a royal pain in the arse.

By way of example, find attached a copy of Troubled Legacy v0.0.15.2 script files updated to use mc instead of ThePlayer... and a couple of other minor tweaks. In fairness, it did take me nearly 2 hours - but I can be bloody minded sometimes when a problem refuses to be easy.

They wouldn't work with your current development version. But I've tested it as best I can (The German translations looked fine) and save files from the existing game worked for the 10+ random saves I created to test it.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,363
15,281
79flavors & Blackthunder_vn

No, I mean, if he has this line in the original script: ThePlayer "Ok, fine."
Now it would be: mc "Ok, fine."
Hey, sorry to derange you, I'm back from my daughter's "birthday with few months late due to the lockdown", so I can be wrong, but aren't you all looking at the wrong ThePlayer ?


The problem come from the fact that define ThePlayer = Character("[ThePlayer]", [...]
is overwrote by the later $ ThePlayer = renpy.input

And the translation problem would come from the fact that define ThePlayer = Character("[ThePlayer]", [...]
would be replaced by define mc = Character("[ThePlayer]", [...]

So... why not just replace define ThePlayer = Character("[ThePlayer]", [...]
by define ThePlayer = Character("[mcName]", [...] ????


A little help of "after_load":
Code:
default mcName = None

label after_load:
    if mcName is None:
        mcName = ThePlayer
        ThePlayer = Character("[mcName]", what_font="Chianti Bold Win95BT.ttf", color="#323ee3")
A correction of the "Variables" label
Python:
label Variables:
    #  The effective default value *need* to be deported here. /None/ have to be 
    # the value for anyone that don't pass this point.
    $ mcName = "Jonas"

    # What is this :/
    $ playerNameinput = "[ThePlayer]"

    $ mcName = renpy.input(_("What's your name?... {i} (Press ENTER for 'Jonas' or type in your choice.) {/i}"))
    $ mcName = mcName.strip()
    if not mcName:
       $ mcName = "Jonas"

   "Hello [ThePlayer]."
And obviously the right definition for the two characters :
Code:
define ThePlayer = Character("[mcName]", what_font="Chianti Bold Win95BT.ttf", color="#323ee3")
define ThePlayer_t_en = Character("{i}[mcName] *thinks*{/i}", what_font="Chianti Bold Win95BT.ttf", color="#323ee3")
And that's all.


As I implied above, my brain isn't at his best, but am I wrong if I say that :
  • The sayer will no change, so no translation issue ;
  • The player name and its sayer will be different again, solving the color issue ;
  • "[ThePlayer]" will still display the player name, what mean that there's not even the need to fix fix ;
 

Blackthunder_vn

Active Member
Game Developer
Jan 31, 2020
582
1,467
I found the Way it works:

The Variable:
label Variables:
$ playerNameinput = "[playerName]"

The Name Choice:
$ playerName = renpy.input(_("What's your name?... {i} (Press ENTER for 'Jonas' or type in your choice.) {/i}"))
$ playerName = playerName.strip()
if not playerName:
$ playerName = "Jonas"
$ ThePlayer.name = playerName

"Hello [playerName]."

The definition of the character:
define ThePlayer_t_de = Character("{i}[playerName] *denkt*{/i}", what_font="Chianti Bold Win95BT.ttf", color="#323ee3")

I dont have to edit the script.rpy ore the german translation works without errors:
Changed all back to the old playerName.

This one Line makes the difference:

$ ThePlayer.name = playerName

Thanks for the help Zenupstart.

It was 1 line to change in the translation.
"Hello [playerName]."

anne O'nymous I see you had the same Idea. Thanks

Thanks for all of your help.
 
Last edited:
  • Like
Reactions: moskyx

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,581
2,219
I found the Way it works:

Certainly for new playthrus. For existing save files, I'm less sure.
I can only suggest testing things.

My impression is that existing users are still going to have issues with the code as you have it now.

Firstly (based on your release 0.0.15.2 code)...

Python:
label Variables:
$ playerNameinput = "[playerName]"

Does nothing. That label is never invoked - but that's okay, because the variable playerNameinput is never used.

Next, existing players are likely to still have problems.

Python:
define ThePlayer_t_de = Character("{i}[playerName] *denkt*{/i}", what_font="Chianti Bold Win95BT.ttf", color="#323ee3")

Uses the variable playerName which will not exist for players loading current saved games.
Though I think you could fix that by changing it to...

Python:
define ThePlayer_t_de = Character("{i}[ThePlayer] *denkt*{/i}", what_font="Chianti Bold Win95BT.ttf", color="#323ee3")

Be careful where you use playerName. That variable won't exist for current save files. The code you've written above would likely work, because "Hello [playerName]." is immediately after the renpy.input(). But if you use it beyond that individual point in the code, it might crash for existing players.

And you're still going to have the problem that ThePlayer is going to be stored in most current save files as a string and not a Character() object. Anne's label after_load: code would fix that. But without something to correct the definition for current players, the ThePlayer_t_de maybe be as you want it, but ThePlayer is still going to be the project's default blue color without any of the customization.

label after_load:
if playerName is None:
playerName = ThePlayer
ThePlayer = Character("[playerName]", what_font="Chianti Bold Win95BT.ttf", color="#323ee3")
[/code]

I did think of after_load, but I wasn't sure if it wouldn't cause more problems than it solves in this case.

Plus, wouldn't ThePlayer here end up being saved to the save file? Albeit, as at least the correct object type.
Actually... Don't answer, it's not something I need to know and I could test it easily enough if I cared about the answer.

Still... it still feels like a solution to solve the symptoms rather than the underlying cause.
Meanwhile... time I was back to shouting at windmills.
 
  • Like
Reactions: anne O'nymous

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,363
15,281
The definition of the character:
define ThePlayer_t_de = Character("{i}[playerName] *denkt*{/i}", what_font="Chianti Bold Win95BT.ttf", color="#323ee3")
Be careful, as it, it will not necessarily solve all the problem.

In an already made save files that occurred after the "Variables" label, and therefore all the play (re)starting with them, ThePlayer will still have for value the name entered through the renpy.input() part.
In this case you'll also need to restore a more acceptable value with the help of the "after_load" label.



Plus, wouldn't ThePlayer here end up being saved to the save file? Albeit, as at least the correct object type.
Actually... Don't answer, it's not something I need to know and I could test it easily enough if I cared about the answer.
But other readers can want to know, so:
ThePlayer is saved starting the moment its value was overwrote by the result of renpy.input() ; except that it's saved as the "string" it became.
Therefore the "after_load" part is just restoring it back, in the game and in the save files, as the Character() object it should have stayed.


Still... it still feels like a solution to solve the symptoms rather than the underlying cause.
It do both.
The change in "Variables" label and the two updated Character() definition are fixing the cause. And the "after_load" label is here to fix the symptoms if they already kicked in.


Meanwhile... time I was back to shouting at windmills.
You know how it is. Sometimes you're so focused on one side of your problem, that you pass by the explanation, totally misreading it as the fear your brain is thinking about. Without that, the thread wouldn't had a second page.
And I know how it is, feel like wasted time.
 
  • Like
Reactions: Blackthunder_vn

Blackthunder_vn

Active Member
Game Developer
Jan 31, 2020
582
1,467
79flavors
the new definition for all ThePlayer is playerName.

define ThePlayer = Character("[playerName]", what_font="Chianti Bold Win95BT.ttf", color="#323ee3")
define ThePlayer_t_de = Character("{i}[playerName] *denkt*{/i}", what_font="Chianti Bold Win95BT.ttf", color="#323ee3")
define ThePlayer_w_de = Character("{i}[playerName] *flüstert*{/i}", what_font="Chianti Bold Win95BT.ttf", color="#323ee3")
define ThePlayer_t_en = Character("{i}[playerName] *thinks*{/i}", what_font="Chianti Bold Win95BT.ttf", color="#323ee3")
define ThePlayer_w_en = Character("{i}[playerName] *whispers*{/i}", what_font="Chianti Bold Win95BT.ttf", color="#323ee3")

these are the new definitions

anne O'nymous

Does it play an role where i put your lines in? Or can i put it in mycharacterdefines.rpy?

label after_load:
if playerName is None:
playerName = ThePlayer
ThePlayer = Character("[playerName]", what_font="Chianti Bold Win95BT.ttf", color="#323ee3")
[/code]

This way? Is it alright so?

Edit: Had errors:

New:
label after_load:
if playerName is None:
$ playerName = ThePlayer
$ ThePlayer = Character("[playerName]", what_font="Chianti Bold Win95BT.ttf", color="#323ee3")
[/code]

2 errors are gone with the $

1 error left:

[/code] = expected statement.

with $

$ [/code] = invalis syntax
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,363
15,281
2 errors are gone with the $
Yeah, this one is clearly my fault. My half working brain made me forgot the $, sorry.


$ [/code] = invalis syntax
You copied the code as quoted by 79flavors. But he was apparently as tired as me, and forgot to include the oppening "[code]".
The [/code] shouldn't be here, it's a formating tag used by the forum, remove it.
 
  • Like
Reactions: Blackthunder_vn

Blackthunder_vn

Active Member
Game Developer
Jan 31, 2020
582
1,467
No problem my brain is also totaly in the butt.

Render Day3 for the game code day3, work on the script, try to learn renpy. it is to much sometimes and it's to late it's 3.46am at the moment.

Thank you very much.

edit: it works.
 

moskyx

Forum Fanatic
Jun 17, 2019
4,005
12,960
Just a silly question from the translation side of things.
79flavors
the new definition for all ThePlayer is playerName.

define ThePlayer = Character("[playerName]", what_font="Chianti Bold Win95BT.ttf", color="#323ee3")
define ThePlayer_t_de = Character("{i}[playerName] *denkt*{/i}", what_font="Chianti Bold Win95BT.ttf", color="#323ee3")
define ThePlayer_w_de = Character("{i}[playerName] *flüstert*{/i}", what_font="Chianti Bold Win95BT.ttf", color="#323ee3")
define ThePlayer_t_en = Character("{i}[playerName] *thinks*{/i}", what_font="Chianti Bold Win95BT.ttf", color="#323ee3")
define ThePlayer_w_en = Character("{i}[playerName] *whispers*{/i}", what_font="Chianti Bold Win95BT.ttf", color="#323ee3")

these are the new definitions
I haven't downloaded your game so I didn't take a closer look at the code, but why did you define 2 sets of characters, one in English and another one in German?

Defining English characters like this:
define ThePlayer_t_en = Character(_("{i}[playerName] *thinks*{/i}"), what_font="Chianti Bold Win95BT.ttf", color="#323ee3")
define ThePlayer_w_en = Character(_("{i}[playerName] *whispers*{/i}"), what_font="Chianti Bold Win95BT.ttf", color="#323ee3")

would make those strings appear in the translation .rpy file so you could translate *thinks* and *whispers*. There's no need to create another set of German characters for them
 

Blackthunder_vn

Active Member
Game Developer
Jan 31, 2020
582
1,467
moskyx My game is in english and german every new version comes in this two languages.

So it is easy to change wile coding in english, make the translation and just switch between en and de.
I have to type in the translation line anyway because the two letters make no difference.

So it's simple and easy for me. My way.
 

moskyx

Forum Fanatic
Jun 17, 2019
4,005
12,960
Well, doing it as I said will save you those 2 extra changes in every line, but that's your choice
 

Blackthunder_vn

Active Member
Game Developer
Jan 31, 2020
582
1,467
It is not so bad to change it and the Brain keeps working.

I think about it if I change the whispering lines of Day1 and Day2.

Thanks