Break lines in plugin command

Status
Not open for further replies.

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,696
Reaction score
1,113
First Language
Portuguese - Br
Primarily Uses
RMMZ
Hi people!

I'm doing a plugin command that puts a text in a help window.
However, I can't make this plugin command put a text with more than one line. When I insert \n or \\n, the line won't break, instead, the text continues.

I can use a script call to put this text too, and it works fine with line breaks.

I only put the 4 plugin commands together to take the print, but I'm not using the four at the same time. But that's is my tries.
changehelp = command
menu = args[0]
0 = args[1]
the rest of the text is the args[2] and so on(using slice and join, to put them together. Maybe it is the cause?).



So, how can I make the plugin command to recognize the \n for line break?
Below is a part of my code. t
Code:
    if(command.toLowerCase() === 'changehelp') {
    let arg0 = args[0].toLowerCase();
    let helpType;
    let helpText = '';
        switch (arg0){
            case "menu":
                helpType = Eli.Param.HelpWindows.menuText;
            break;
            case "itemcategory":
                helpType = Eli.Param.HelpWindows.itemCtText;
            break;
            case "skillcommand":
                helpType = Eli.Param.HelpWindows.skillTypeText;
            break;
            case "equipcommand":
                helpType = Eli.Param.HelpWindows.equipCmdText;
            break;
            case "equipslot":
                helpType = Eli.Param.HelpWindows.equipSlotText;
            break;
            case "options":
                helpType = Eli.Param.HelpWindows.optionsText;
            break;
            case "gameend":
                helpType = Eli.Param.HelpWindows.gameEndText;
            break;
        };
        helpText = args;
        helpType[args[1]] = helpText.slice(2).join(" ");
    };
 

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
856
First Language
English
Primarily Uses
RMMV
@Eliaquim Is this a custom help window, or the standard help window? Is the window using the drawText or drawTextEx function to print the text? The text in the first two plugin commands should work.
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,696
Reaction score
1,113
First Language
Portuguese - Br
Primarily Uses
RMMZ
Hi @Ossra !
It's not a custom one. It is the standard, that I put in the scene menu.
Code:
Scene_Menu.prototype.create = function() { // overwrite
    Scene_MenuBase.prototype.create.call(this);
    this.createHelpWindow();
    this.createCommandWindow();
etc...
}

Scene_Menu.prototype.createHelpWindow = function() {
    this._helpWindow = new Window_Help();
    this.addWindow(this._helpWindow);
}

Eli.HelpWindows.Scene_Menu_createCommandWindow = Scene_Menu.prototype.createCommandWindow;
Scene_Menu.prototype.createCommandWindow = function() {
    Eli.HelpWindows.Scene_Menu_createCommandWindow.call(this);
    this._commandWindow.setHelpWindow(this._helpWindow);
}
};

Hmm...
Now that you talk about the drawText and drawTextEx, I realize that I never though about that.
But I guess that is the drawTextEx because I can use other escape characters like \c[x] \v[x] etc.

But the plugin is setting the text with the function:
Code:
.setText('text here');
That I think that can be found here(RM MV 1.6.2):
Code:
Window_Help.prototype.setText = function(text) {
    if (this._text !== text) {
        this._text = text;
        this.refresh();
    }
};

Window_Help.prototype.refresh = function() {
    this.contents.clear();
    this.drawTextEx(this._text, this.textPadding(), 0);
};
[[[EDIT]]]] - When I put the text through the parameter(
@type note[] ) of the plugin, it works ok. I press ENTER there, and the \\n appears in the parameter(text).
I think that maybe this is related to how I set the parameter?
Code:
menuText: JSON.parse(Eli.Parameters['Menu Help Text'] || '[]').map(JSON.parse),
 
Last edited:

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
856
First Language
English
Primarily Uses
RMMV
@Eliaquim Hmm, well, from what I see of your code and what you have described, the text should be displaying properly. Is it possible to share the code for the entire plugin?
 

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
856
First Language
English
Primarily Uses
RMMV
@Eliaquim Tack a 'replace' onto the end of the line which is joining the argument array :

Code:
helpType[args[1]] = helpText.slice(2).join(" ").replace(/\\n/g, '\n');
The issue seems to be that the newline character is not being properly converted.
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,696
Reaction score
1,113
First Language
Portuguese - Br
Primarily Uses
RMMZ
@Eliaquim Tack a 'replace' onto the end of the line which is joining the argument array :

Code:
helpType[args[1]] = helpText.slice(2).join(" ").replace(/\\n/g, '\n');
The issue seems to be that the newline character is not being properly converted.
You read my mind xD
Thanks for the fix! I was already a lot of time trying to figure it out ^^
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,842
Reaction score
5,228
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Are we allowed to post about non-RPG Maker games?
I should realize that error was produced by a outdated version of MZ so that's why it pop up like that
Ami
i can't wait to drink some ice after struggling with my illness in 9 days. 9 days is really bad for me,i can't focus with my shop and even can't do something with my project
How many hours have you got in mz so far?

A bit of a "sparkle" update to the lower portion of the world map. :LZSexcite:

Forum statistics

Threads
105,883
Messages
1,017,236
Members
137,608
Latest member
Arm9
Top