Another user on the Discord server was wanting to be able to pass through a player name to their Yarn script in GD5.
While the documentation shows how you can pass events/commands out of Yarn, there doesn’t appear to be any way to pass commands/variables into yarn. You can manipulate Yarn variables within your Yarn script itself, but not pass data from the Global/Scene/Event variables in the main GD5 IDE.
This made us discuss workarounds, and one thought was to just store the Yarn script as a variable then do a replace on the string…only to find out there isn’t a Replace expression in GDevelop. At least not one we can find in the documentation or searching the expression finder.
Substrings are not a valid alternative to the replace() function from Javascript, especially when you consider the use case the user had. If you allow custom character names, a normal dialogue is going to have numerous instances of that player name. Meaning you’d have to do a LOT of substring/add variable/append to new string before you can pass it back. This would be overly complex and prone to error.
With that said, since Javascript natively has a replace() expression, I wanted to throw the request on here to get Replace added to GD5. Even unrelated to Yarn, this function is exceptionally helpful for multiple use cases.
I think there are generally many little functions like that that are required or just to make life easier that miss. We should make a list of them and someone (me or someone else with JavaScript knowledge) would make a little built-in extension for that.
4ian already responded around which already exist, but I definitely feel like there’s no easy way to replicate Replace currently. There was mention of a card being created, but I’m not finding it on Trello.