m_from_space wrote: ↑Wed May 25, 2022 3:58 pm
I suggest:
Code: Select all
call hike_say(_("This is a sample, addressing the player with the player's name in a variable: Hello {nw}"))
extend "[playername]!"
Okay, that's an elegant workaround, thank you!. I should have come up with that, too.
Looks like I'm not smart enough.
EDIT: However, it doesn't work as easily! Or actually, at first it does, so the text translates and is displayed, but then it's immediately replaced by:
It took me a while to find the reason for that, although it's fairly easy: the variable
text is only defined in the function, but the extend command happens after the function had been called in the main program, so Ren'py doesn't know the variable
text then and so just prints the "source code".
I found a fix for that, however: I just define the variable in the main program with the same value:
Code: Select all
$text="This is a sample, addressing the player with the player's name in a variable: Hello {nw}"
call hike_say(_("This is a sample, addressing the player with the player's name in a variable: Hello {nw}"))
extend "[playername]!"
Then it finally works!
Fortunately, there are only three such instances where the player is addressed directly, otherwise that would be tedious.
So thanks again for the help! That was surprisingly tricky, I must say...