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?
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)
.
@MrMen
OK, but is it possible to insert the Variable_name content in a Yarn dialog string ?
Thanks,
J
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 ?
Thanks,
J
Use the File System’s action “Load text from a file”.
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 ) :
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 :
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