DadGuyDrawing

Veteran
Veteran
Joined
Apr 15, 2020
Messages
91
Reaction score
36
First Language
English
Primarily Uses
RMMV
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!
 

DadGuyDrawing

Veteran
Veteran
Joined
Apr 15, 2020
Messages
91
Reaction score
36
First Language
English
Primarily Uses
RMMV
What a great answer, thank you!
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
3,811
Reaction score
2,870
First Language
EN
Primarily Uses
RMMZ
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."
 

Latest Threads

Latest Profile Posts

I know I'll put one of my game's sprites here to give the illusion that I am a productive member of game society.
handelspriteanim.gif
Preparing untested English localization for DOWNFALLEN.

unknown-43.png
Sometimes I wonder if I feature creep... 225 magic spells is a lot lol.

Forum statistics

Threads
124,500
Messages
1,164,060
Members
163,329
Latest member
milkpowder
Top