Replace string (from text or variable) into Yarn using RegEx?

In my game, I want the player to choose their name (and pronouns later but that’s just a bit more complex version of this), in which my dialogue in Yarn can display that name within the given dialogue. I tried to follow the only source I could find on it, this closed topic here: [Solved] Custom player name in Yarn dialogue?

However the name is distinctly not replacing the string using the Regular Expressions extension as in the tutorial. Instead Yarn just shows the placeholder text “@goodstring@”

Now I need to explain some quick things. I have it set up so the player name can only be made using characters I have said it’s allowed to use. This turns the black text (Black Fish), into the allowable “good string” (Green FISH). When I confirm my name this sends the good string to a global variable of the player name (Red Null). After Confirm is pressed this doesn’t happen. “@goodstring@” should be replaced with FISH as seen in the red text. As you can see it isn’t. As well the white text indicates there is an error with loading the file, but I’m not sure where or why.


(I’m currently allowed one picture :confused: )

This is the code for replacing the name, and as far as I know this is identical in form to the previously mentioned tutorial (The “g” was replaced with an “i” to test if that would fix it and it didn’t, both do not work). The blacked out part in the file location is just a privacy thing, and yes there are two confirm button inputs and I have tried many variations and none have worked that was just my last.

Any ideas on how to get it working, or alternatives to achieve the same effect?

Your events seem a bit odd to me. Are you trying to run it in an extension/function?

I am not trying to run it in an extension. What do you mean by odd? Most code of mine is a mix between tutorials and bodging so it might look strange.

Update: I was able to get the name replaced if I manually copied the Yarn JSON into the variable, meaning the issue came from the fact that GDevelop was refusing to load the dialogue file. The question now is, why won’t the file load?

Update & Solution: GDevelop appears to not understand what file locations are unless all '\ ’ are '\\ ’ This appears to have solved the problem. You can go ahead and mark it as solved, with the following as my solution for those who find this with a similar issue:

Load the text at the beginning from it’s location with all '\ ’ as '\\ ’ into the designated first base scene variable.

Then in a second scene variable, hosting the updated version, set it to: “RegEx::Replace(”(“placeholder”,“g”,VariableString(first_base_variable),GlobalVariableString(player_name))"

finally load the dialogue data from the updated second scene variable. That should hopefully work.

To be clear, this event right here didn’t look right to me.
image

However, this appears to be an editor bug, not on you. It just threw me for a loop. I’m reporting it on the github now.