Line breaks in battle UI text?

So, my game uses oddly-sized text boxes, and the default battle UI puts the '%1 has been defeated' messages and the like above the text box. If I could add a single line break to push the text down, it'd fit perfectly, but I can't figure out how to do that. Is there something I'm missing?
Hi there!
I don't know if it supports by default, but if you use the escape code \n it will do a line break on the text. If this window support escape codes.
Hi there!
I don't know if it supports by default, but if you use the escape code \n it will do a line break on the text. If this window support escape codes.
Escape code? What do you mean by that?

EDIT: Nevermind, I realized what you meant. You're referring to your plugin, right? I tried that, but it doesn't do a line break. Are you sure the command is \n?
Escape code? What do you mean by that?

EDIT: Nevermind, I realized what you meant. You're referring to your plugin, right? I tried that, but it doesn't do a line break. Are you sure the command is \n?
No, it's not about my plugins. Escape codes is a term that we use, on RPG Maker context, to reference these codes:
1662326866899.png

You can use them in text. Each one has a different purpose. Although \n is not listed there, it is, let's say, a default Escape code on javascript strings.
When you type \n it is supposed to do a line break.

If it doesn't do a line break, then the Window itself does not support the line break.
So maybe you can try a plugin that I did that lets you use those escape codes on any window inside the game.

You will also need my core plugin for it to work:
No, it's not about my plugins. Escape codes is a term that we use, on RPG Maker context, to reference these codes:
View attachment 239654
You can use them in text. Each one has a different purpose. Although \n is not listed there, it is, let's say, a default Escape code on javascript strings.
When you type \n it is supposed to do a line break.

If it doesn't do a line break, then the Window itself does not support the line break.
So maybe you can try a plugin that I did that lets you use those escape codes on any window inside the game.

You will also need my core plugin for it to work:

Alright, I've installed your plugins, but it's still not working. How compatible are your plugins with Yanfly's? Should I order them in a specific manner around his plugins?
Alright, I've installed your plugins, but it's still not working. How compatible are your plugins with Yanfly's? Should I order them in a specific manner around his plugins?
I don't about any problems with Yanfly with these two plugins.
What I know is that Eli Book must be somewhere above the Global Text plugin.
After that, you can try playing with the Global Text position on the plugin manager.
And try setting the Automatic Mode to true on the plugin parameters.

But before that, you can show a screenshot just for me to see and make sure I know what window you are talking about?
I don't about any problems with Yanfly with these two plugins.
What I know is that Eli Book must be somewhere above the Global Text plugin.
After that, you can try playing with the Global Text position on the plugin manager.
And try setting the Automatic Mode to true on the plugin parameters.

But before that, you can show a screenshot just for me to see and make sure I know what window you are talking about?
1662413067304.png

This is the issue. I'm using Galv's script to replace the text boxes with images. The first line is used as a replacement for a name box, and then the lower lines are used for the text itself. Everything defaults to the first line, which is where the issue arises.
View attachment 239764
This is the issue. I'm using Galv's script to replace the text boxes with images. The first line is used as a replacement for a name box, and then the lower lines are used for the text itself. Everything defaults to the first line, which is where the issue arises.
Ok, so this is the Message window, right?
If yes, the escape codes should work without any plugins.

Did you try to put the \n before the text?
Ok, so this is the Message window, right?
If yes, the escape codes should work without any plugins.

Did you try to put the \n before the text?
That's what I did, but it didn't work. It's one of the automatic text boxes altered by the 'Terms' menu of the database.
Well, if you are talking about the message window, and it didn't work, maybe it is a compatibility issue. Don't know what else it can be.
Well, if you are talking about the message window, and it didn't work, maybe it is a compatibility issue. Don't know what else it can be.
I see 🙁 Well, thank you for trying to help. I'll look into some alternatives, maybe getting rid of the boxes altogether...
The most frustrating thing is that I ran into a similar problem and it did not help me either, you found a solution that would work for you.
The "\n" escape code doesn't work because the engine is not built to allow it. It actually saves all single backslashes that you type in the database as double slashes "\\" in the actual database JSON files. This includes when using the Show Message command, the engine only records a newline character when you use a different line in the text box.

Of course, unlike Show Message, the battle messages in the Terms tab don't have a multi-line text box for input. So you can't manually do that for them.

If you really want to add that new line for battle messages, you will need to make modifications under the hood. Either with a plugin, or by directly tweaking the internal Javascript files that comprise the engine.

There's multiple ways to do it.

The BattleManager object in "rpg_managers.js" is the bit of code responsible for telling the message box to display those messages in battle (see the functions named "BattleManager.displayDefeatMessage" and "BattleManager.displayVictoryMessage" and the like) among many other battle-related functionalities.

It then sends the line of text to "$game_message" (the Game_Message object, located within "rpg_objects.js") which is code that adjusts and stores the message box settings like scroll speed and face windows and also all the text meant to be displayed. The actual message box window, Window_Message (in the file "rpg_windows.js") reads the Game_Message object for the settings and then displays whatever text is being held in it.

So one way is to adjust the BattleManager to force it to send an extra blank line of text before all its messages, like so:
BattleManager.displayDefeatMessage = function() { $gameMessage.add(""); $gameMessage.add(TextManager.defeat.format($gameParty.name())); };
Or else you can tweak Game_Message to check if it is in battle when it stores text and force it to add an extra line (this can be messy, since if there is any circumstance where multiple lines are meant to be displayed at once, there will also be spaces added between them and then you will need to tweak it further if you want the only newline to be on the first line):
Game_Message.prototype.add = function(text) { if (SceneManager._scene.constructor.name == 'Scene_Battle') { this._texts.push(""); } this._texts.push(text); };
However, if I were personally doing it, there's another way, one that I would personally consider cleaner/faster, which is just to manually hack the TextManager.

All the lines of text in the database Terms tab are loaded and stored by the TextManager object when the game boots up (again, it is located in "rpg_managers.js" like the BattleManager). This TextManager is actually what the BattleManager looks up when it sends the defeat/victory/etc. messages, rather than the database files.

You can see where TextManager loads the text in this part of the code:
Spoiler: Line 1679 in rpg_managers.js
Object.defineProperties(TextManager, { level : TextManager.getter('basic', 0), levelA : TextManager.getter('basic', 1), hp : TextManager.getter('basic', 2), hpA : TextManager.getter('basic', 3), ... ... victory : TextManager.getter('message', 'victory'), defeat : TextManager.getter('message', 'defeat'), ... ...
It normally calls a bunch of its own functions like "TextManager.getter" and "TextManager.method" to load the text from the database files (the Terms tab stuff is all stored in the "System.json" file).

It is possible to hack it so that instead of loading the text from the database files, the text is hardcoded straight into the TextManager like so:
defeat : {get: function() { return "\n%1 was defeated."} , configurable: true},

You may be wondering - why hack TextManager? Why can't you just hack the System.json file instead?

After all, if the problem is that the engine is storing your "\n" as a "\\n" in the database files, you can just open up the System.json file in notepad and modify it so that it looks like:
"defeat":"\n%1 was defeated."
Instead of:
"defeat":"\\n%1 was defeated."

And the answer is, yes, you can. But then everytime you click the Save button in the RPGMaker MV engine, it will just overwrite your file and put back the double slashes. So unless you are never going to touch the database again after modifying the .json file, the most practical way is to modify TextManager instead.

Original thread: https://forums.rpgmakerweb.com/threads/line-breaks-in-battle-ui-text.151065/