Help with calling variable names inside a string

I know that typically in a text box you can make calls like \n[x] for actor names and \v[x] for variable values etc and that you can call them long form with $game_variables[x], but I'm having some issues with a particular script for making a quest log, linked below:


The script is actually really nice and simple; you create a new quest with the command:
$game_system::add_active_quest("Questname", "Quest Description", "Reward1, Reward2,..." )

My issue is that I cannot seem to call any variable names or actor names from within the Quest description. I suspect this is because the quotes turns it into a string and it does not properly evaluate the call. In ruby is there some way to either concatenate strings or to have the script correctly evaluate the name calls within the larger string?
If I'm understanding correctly you would normally just break up the string and add the variables to it.

For example:
$game_system::add_active_quest("Questname", "Quest Description part 1" + variable + "Quest description part 2", "Reward1, Reward2,..." )

Just make sure to use the correct notation for the variables you want to include.
As a guess, try putting \\n[x] and \\v[x] instead of \n[x] and \v[x]

The script seems to call the correct function to process the escape characters.

I've moved this thread to RGSSx Script Support. Thank you.

I'm not sure if I fully understand your goal but this might help you, so try adding an e. Like this:
Code:
\eV[x]

Edit: it's possible this only works from within variables and thus wouldn't help you. Sorry if it doesn't.
If I'm understanding correctly you would normally just break up the string and add the variables to it.

For example:
$game_system::add_active_quest("Questname", "Quest Description part 1" + variable + "Quest description part 2", "Reward1, Reward2,..." )

Just make sure to use the correct notation for the variables you want to include.


This is exactly the type of concatenation I was looking for! Thank you!
I'm so used to dealing with strings and variables inside of MATLAB, that I have trouble figuring out how they work in real languages.
Be careful. Ruby does not coerce type conversion so a number WON'T be converted to a string automatically. You'd need to use string interpolation or call variable.to_s if setting a string with the + operator.

Original thread: https://forums.rpgmakerweb.com/threads/help-with-calling-variable-names-inside-a-string.124464/