[Solved] Custom player name in Yarn dialogue?

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) :

image


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 :

yarn_dialogue


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
6 Likes