Numeric value of a variable in the string variable text

Hello, a quick question, how do you make the "" string text of a variable show \v values ? \ or \\ doesn't work and i'm out of ideas. Please delete the thread if this is a stupid question 🙂

["bla bla bla \v[20] +resource bla bla"], just shows ::::bla bla bla... [20] +resource bla bla

edit: its really making it difficult to show numerical reports on a panel, is the problem.
edit 2: i made the next line of report purely on numerics problem solved (facepalm)
looks a bit ugly :🙂
1664699454393.jpeg
Hmm, I cannot see in what "environment" you are. \V etc. is implemented by the RPG Maker code, this is why RPG Maker converts \V[x] into their values only in Messages or some other Windows. When you are programming with JS, the \V[x] will not work.

To programmatically get a variable's value, you can do this:
const message = "You have got " + $gameVariables.value(1) + " resources."
Doesn't matter whether your Variable itself is a string or a number.

If you are programming a custom Window that inherits from Window_Base, you can do this:
this.drawTextEx("You have got \V[1] resources.", x, y, width)

Maybe you should screenshot your Eventing / JS codes so I can better understand what you are trying to do.
Thank you for the response. I can somehow guess that there's is scripting around all these problems. However i've kept it simple and never learned js required instead just used my common knowledge of C to copy/paste simply codes around everywhere. (there's only one array level sorting code for rank and a few lines of scripts in all)

I'm very simply transferring the string to hud maker plugin/software's variable slot. I suppose code should also work there. I'll test it later since i've moved on to other work on checklist 🙂
(you can also see the manual stack, 5 lines etc, i'd rather do this than learning code etc, since otherwise very bug prone and huge number of coding for everything it gets mixed 🙂

1664702820489.png
Okay, so when I look at your screen, I can see that you assign Variable 1010 with a script. Then you want to type

Code:
"Monthly faction numbers are received: " + gameVariables.value(1) + " Gold"
The \v[n] control character only works in text that passes through
Window_Base.prototype.createTextState(), such as the Show Text... event command and such. Also, strings injected into messages via \v[n] are not passed through createTextState() again.

If you are managing your string yourself, you should use a template string instead:
JavaScript:
const value = "cruel";
const message = `Hello ${value} world`;
will store "Hello cruel world" into message.

So if you instead want to inject the value at variable #0020, the template string would look like this instead:
JavaScript:
`Hello ${$gameVariables.value(20)} world`

Note that the quote marks for template string is not the same as the quote marks for regular strings. For regular strings, it's either the double quote mark " or the single quote mark ' (aka apostrophe). For the template string, it's the backtick ` instead. You can inject the result of any expression, including things like ${1 + 3}, which will inject 4 into your string.
The \v[n] control character only works in text that passes through
Window_Base.prototype.createTextState(), such as the Show Text... event command and such. Also, strings injected into messages via \v[n] are not passed through createTextState() again.


Note that the quote marks for template string is not the same as the quote marks for regular strings. For regular strings, it's either the double quote mark " or the single quote mark ' (aka apostrophe). For the template string, it's the backtick ` instead. You can inject the result of any expression, including things like ${1 + 3}, which will inject 4 into your string.
I thought problem was this. Thank you, this makes sense to me alot.
It works as pasted in script window =
`Hello ${$gameVariables.value(24)} world`
thanks

rant ahead:
draw Window (variables) stuff was very rigid without much expertise, so i opted out for plugin for log report panel.
scripts that are in a language unfamiliar to me is sort of scary with all their potential uses. Its just that in a game with so many calculations, the advanced algorithms are never needed, at all, which is sorta.. strange. Well as long as the game is bug free.. I suppose it always goes towards user interface and shuffling the math as a game developer, with so many freebies around. I forgot the $~ i suppose since the other engines' syntax differs, i was used to always using variables via simple interface. What really creates bugs is the ordering of events and measuring of time, which can also be implemented simply 🙂 Using autorun for cutscenes helps a lot. Label use is really helpful also.
For faction wise battles and other stuff, it was a matter of simply making variables that are refined and calculated from others. I didn't have time to implement ai like features, but it all depends on random function. Randomness were important to me, for it to be a living world (ie other heroes gain (variable) increase/decrease as with certain amount of time and can solve quests etc if hero spends too much time for other things. What i'm saying is, its lots of simple level coding for such an unused feature in games.

edit: i've looked and most complicated piece of coding in the game is changing event's move type for courier that calculates distance as it gets near to hero, which i guess if i made it again wouldn't be necessary. Some auto switch panels also have some complicated stuff. The parallel eventing and autorun eventing matters a lot i guess, so two processes don't play the same event at the same time, corrupting data. Changing the count down timer's appearance etc, how would this kind of engine altering would actually help besides the story being important, for a timed quest. it all seems pointless lol.
Okay, so when I look at your screen, I can see that you assign Variable 1010 with a script. Then you want to type

Code:
"Monthly faction numbers are received: " + gameVariables.value(1) + " Gold"
quickly checking, it works, thank you. (variable is 24, etc) to 1001 of course.

Original thread: https://forums.rpgmakerweb.com/threads/numeric-value-of-a-variable-in-the-string-variable-text.151711/