Issue with displaying variables inside a text box

What I'm trying to do is show icons and variables corresponding the actor's equipment and resistances on the right side of my text box during a message in battle. But the message keeps pushing the information back, messing up the alignment. Normally this is a good thing, since it makes variables fit neatly inside a sentence. But when I'm trying to show text I want to stay still it's becoming an issue for me.

Here is what my text window Looks like:

Text : E.Faces1_Edited(o), Window, Bottom
: :\f[\V[51],\V[52]]\>\V[50] \V[19]
: :\>\V[20]!___________________\I[143]\V[1065]
: :____________________________\I[137]\V[1066]
: :____________________________\I[139]\V[1067]

What I would like is for the text inside variable 20 not to push back the placement of \I[143]\V[1065].

Is this possible to do? (The underscores are spaces.)
Hi there!
Can you show a screenshot of the message?
I never tested something like that myself, but maybe is related to the size of the text replaced by \v[20].
Or maybe because of the "\>"

Are you using any custom plugins for that?
Assuming variable 20 is a word/string, and that you aren't displaying it anywhere else in the game except in this box:

Could you try adding spaces to the end of variable's value itself, when setting it, to ensure that it will always take up the exact amount of space needed depending on the length of the word?

Example:

Code:
$gameVariables.setValue(20, 'Brad          ')
$gameVariables.setValue(20, 'Jacob         ')
$gameVariables.setValue(20, 'fly           ')
$gameVariables.setValue(20, 'midnight      ')
What I'm trying to do is show icons and variables corresponding the actor's equipment and resistances on the right side of my text box during a message in battle. But the message keeps pushing the information back, messing up the alignment. Normally this is a good thing, since it makes variables fit neatly inside a sentence. But when I'm trying to show text I want to stay still it's becoming an issue for me.

Here is what my text window Looks like:

Text : E.Faces1_Edited(o), Window, Bottom
: :\f[\V[51],\V[52]]\>\V[50] \V[19]
: :\>\V[20]!___________________\I[143]\V[1065]
: :____________________________\I[137]\V[1066]
: :____________________________\I[139]\V[1067]

What I would like is for the text inside variable 20 not to push back the placement of \I[143]\V[1065].

Is this possible to do? (The underscores are spaces.)
I dont think thats possible, since every time the number in v20 changes, so does the space between it and v143, so 143 will always be off.. like here:
1648018925027.png

What you could do is put v20 somewhere else or use a plugin.
Or another option would be to make a conditional branch wich asks if you got 1,2,3 ect... digits in v20, and change the text box with different spaces, since it wont matter if the number is 11 or 99, the space will be the same, same goes for 0-9, or in 3 digits 111-999 ect....
something like this:
1648019519612.png


hope this helps.
I assume you're already using at least one message plugin (Shaz's More Escape Codes?), because \f is not a default text code.

YEP Message Core has a \px text code that allows horizontal positioning:
(MZ has this text code by default.)
Hi there!
Can you show a screenshot of the message?
I never tested something like that myself, but maybe is related to the size of the text replaced by \v[20].
Or maybe because of the "\>"

Are you using any custom plugins for that?
Text Box_Forum Help.png


I'm pretty sure it is related to the size of the text replaced by \V[20]. It spaces the line forward for each digit or letter included, which normally is a good thing since it allows for you to easily insert words into a sentence. But it's causing me some problems when I want to include other information inside a text box.

I'm using MoreEscapeCodes2 authored by Shaz. But I think \> is a basic command. It just speeds up the message speed so the text appears all at once.
What you're trying to accomplish is really outside the scope of escape codes that I've seen, because you're asking for that center area to be dynamically created. Obviously, if you type in ten spaces or whatever, those ten spaces will be printed and push the rest of your text to different places if the contents of your variables are different.

You'd need to write a JavaScript function that takes the two variables that will be printed and calculates how much space to insert in between them.

This is fairly trivial, but it depends on how many characters wide your text boxes are, which is something you may have modified. I think you might be able to use that function with caethyril's custom escape codes plugin.
Assuming variable 20 is a word/string, and that you aren't displaying it anywhere else in the game except in this box:

Could you try adding spaces to the end of variable's value itself, when setting it, to ensure that it will always take up the exact amount of space needed depending on the length of the word?

Example:

Code:
$gameVariables.setValue(20, 'Brad          ')
$gameVariables.setValue(20, 'Jacob         ')
$gameVariables.setValue(20, 'fly           ')
$gameVariables.setValue(20, 'midnight      ')

Sorry I should have made that clear. Variable 20 is made up of words.

And this appears to be working, so thank you very much. I use these variables elsewhere, but that's no biggy because I can just make some new ones for this specific situation.

Is there a way I can include apostrophes in the text? Because when I do use them I get a SyntaxError missing ) after argument list.
I dont think thats possible, since every time the number in v20 changes, so does the space between it and v143, so 143 will always be off.. like here:
View attachment 220745
What you could do is put v20 somewhere else or use a plugin.
Or another option would be to make a conditional branch wich asks if you got 1,2,3 ect... digits in v20, and change the text box with different spaces, since it wont matter if the number is 11 or 99, the space will be the same, same goes for 0-9, or in 3 digits 111-999 ect....
something like this:
View attachment 220746

hope this helps.

Thanks for taking the time and the detailed response.

I should have made it clear that variable 20 is made up of words and can be over 30 letters in length. So I'm not sure how feasible this method would be for this specific problem.

Basically what I have is a message that appears in battle describing the kind of attacks my enemies are going to use. So the variable will change depending on what attack pattern is selected.

This will work great though for when I want to display stats in a text box and align my numbers. So I'm sure you saved me a future trip to the forums.
I assume you're already using at least one message plugin (Shaz's More Escape Codes?), because \f is not a default text code.

YEP Message Core has a \px text code that allows horizontal positioning:
(MZ has this text code by default.)

How easy is it to convert a current project on MV over to MZ? Because that's the only reason I haven't bought it yet.
What you're trying to accomplish is really outside the scope of escape codes that I've seen, because you're asking for that center area to be dynamically created. Obviously, if you type in ten spaces or whatever, those ten spaces will be printed and push the rest of your text to different places if the contents of your variables are different.

You'd need to write a JavaScript function that takes the two variables that will be printed and calculates how much space to insert in between them.

This is fairly trivial, but it depends on how many characters wide your text boxes are, which is something you may have modified. I think you might be able to use that function with caethyril's custom escape codes plugin.

Yeah, I put the spaces there believing it would give my variable room to print without affecting my icons and variables to the right of the text. So that was probably not a smart assumption on my part.

So far I'm having some luck getting the effect I want by including spaces in the code itself like Ratatattat suggested. So hopefully that continues to pan out. If it doesn't, I'll look into that plugin you suggested.

It's been a few years since I worked on my project so I couldn't really remember what specifically I used those plugins for.

@Berylstone, please avoid double posting, as it is against the forum rules. You can use the "Edit" function on your posts to add additional information you've forgotten or respond to multiple people. You can review our forum rules here. Thank you.

You can use the +Quote button to quote multiple people, and the Edit button to add information to your post. 👋

How easy is it to convert a current project on MV over to MZ? Because that's the only reason I haven't bought it yet.
I think the data and image/audio stuff should transfer as-is. Plugins are another matter: there are quite a few MV plugins that don't work correctly in MZ. FOSSIL helps to an extent, but it doesn't work for everything.

If you want to avoid Message Core because it adds too many other features, then like @ATT_Turan mentioned, I have an MV plugin that lets you define your own custom text codes:
With that plugin, you could try making a Process Escape Code with these settings (untested):
  • Code: px
  • Arguments: 1 x Integer
  • Delimiters: []
  • Replacer: this._textState.x = parseInt(arguments[1], 10);
Then use as: \v[1]:\px[400]offset. \px[400] should make the text jump to 400 px from the left edge of the message window.
I should have done this from the beginning, but here is a screen shot of how the text box looks on the game itself so you can have a better understanding of what I'm doing:

Text Box1_Forum Help.png


Variable 20 is what you see on the second line to the left of the armor icon.
Ooh, nice screenshot!
Double-post notice: @BerylstoneYou can use the +Quote button to quote multiple people, and the Edit button to add information to your post. 👋


I think the data and image/audio stuff should transfer as-is. Plugins are another matter: there are quite a few MV plugins that don't work correctly in MZ. FOSSIL helps to an extent, but it doesn't work for everything.

If you want to avoid Message Core because it adds too many other features, then like @ATT_Turan mentioned, I have an MV plugin that lets you define your own custom text codes:
With that plugin, you could try making a Process Escape Code with these settings (untested):
  • Code: px
  • Arguments: 1 x Integer
  • Delimiters: []
  • Replacer: this._textState.x = parseInt(arguments[1], 10);
Then use as: \v[1]:\px[400]offset. \px[400] should make the text jump to 400 px from the left edge of the message window.

That's what I was worried about. My game is pretty reliant on some of the addons I believe, especially the ones that allow me to show variables in menu screens and file loads. It would be a major pain to have to go back through them all and change. I will get it eventually for the extra music and graphic resources, but I'll probably stick to MV till my game is done (if it's ever done).

Ooh, nice screenshot!

Ty. It's been a while since I used the forum and had forgotten how easy it was to use screenshots. I also forgot about the multi quotes, which I'll use in future. I like to try to respond to as much as I can so people don't think they're wasting their time when they help.
Seen all your replies, if you don't want to change to MZ, I have some plugins that may help you out.
But that would require you to change some of your plugins setups. Depending on how you did it, it can be a lot of work or not.

My Message Action plugin, lets you define the alignment of the text on the message.

So you could type:
\>\V[20]!\Align[type]\I[143]\V[1065]
(replace type with "right")

So the \v[1065] will always stay in the right position of the message.
something like that:
1648074530769.png


Spoiler
Message Action

Need Core Plugin:

Global Text(Let's you write any escape code on any game window:

Escape codes (add more escape codes)
Is there a way I can include apostrophes in the text? Because when I do use them I get a SyntaxError missing ) after argument list.

I believe if you insert a backslash before the apostrophe, it'll indicate that it should be read as a literal apostrophe rather than ending the string 🙂

So something like:

Code:
$gameVariables.setValue(20, 'Sun\'s Fury')

But this...
My Message Action plugin, lets you define the alignment of the text on the message.
...also looks like a great option!

Original thread: https://forums.rpgmakerweb.com/threads/issue-with-displaying-variables-inside-a-text-box.146030/