[Solved] Custom player name in Yarn dialogue?

Wondering if it’s possible to let the player choose their own name and have the dialogue refer to them as said custom name.

I feel like there’s a little work around it but I don’t know.

Could this be possible?

Sure. Use an input text box (experimental) to get the name, and store the text in a global string variable. Then reference that global string variable when you need the name using GlobalVariableString(variable_name).


OK, but is it possible to insert the Variable_name content in a Yarn dialog string ?

1 Like

Ah, sorry, I missed the reference to dialogue.

I haven’t tested this, but it seems feasible. You could load the JSON file into a variable, replace the placeholder for the player’s name with the global variable value and then load dialogue data from the variable.

I’m not able to load the json dialog file into a variable.
How to do it ? Have I to load all the file or any single string ?

Use the File System’s action “Load text from a file”.

Here’s how I did it :

This is part of my dialogue tree. It’s from the example template that comes with GDevelop. I modified it to have a place holder for player name (highlighted in green) :


Here is my player_name varariable setup (I skipped the input text box bit :slight_smile: ) :

These are the actions I used to replace the player’s name. I installed the RegEx extension for the 2nd action (note the dialogue action in the screen snip below has a bug in it - it shows _PARAM1_ instead of _updated_dialogue) :

And here’s the output :


As a side note, the regex replace expression uses 4 parameters :

  1. the pattern to search for (’“player_name@” in this case)
  2. regex flags (scroll down to flags on this web site for an explanation)
  3. the original string (in this case, the loaded dialogue text)
  4. the replacement value (for strings found with parameter 1), which in this case is the user chosen name

WOW, thanks.
It helps me a lot.

thanks for the great tutorial!
but I have a question, why in the reg you mentioned the seconds string as "g"?

It’s in the link I provided :

thank you so much
: D