RMMV display variables within variables

Hi All,

I'm trying to generate text for dialogue in a script that includes NPC names stores as variables, but when I set a message to a text variable that includes a variable reference, the program just prints the variable reference name, rather than the content.

So for example:

I want this = "Hi, my name is Joe. I like games."

Variable 1 = "Joe"
Variable 2 = "Hi, my name is \v[1]. I like games."

However, when I place the variable 2 in the game message, I get "Hi, my name is \v[1]. I like games." Without the contents of varaible 1.

I've worked around this by splitting the dialogue into multiple variables (eg v1 = "Joe" v2 = "Hi, my name is" and v3 "I like games."), but it makes my script generated dialogue a lot more difficult. Also this same problem has come up multiple times, so I was curious if anyone could help.

Question 1: Can anyone explain how the game decides when to read for variables and icon codes and when it just reads it as text?

Question 2: Has anyone else encountered this problem and found a good solution?

Thank you community for your help!
Variable and icon codes will not work inside strings. Anything that's inside "" will become text.
Use script calls for situations like this:
1599918008236.png
What a great answer, thank you!
It's actually because backslashes get replaced by the \x1b escape character prior to processing. Thus, an alternative would be:
  • Variable 2 = "Hi, my name is \x1bv[1]. I like games."
That helps a lot Caethril, thank you!

Original thread: https://forums.rpgmakerweb.com/threads/rmmv-display-variables-within-variables.127236/