Status
Not open for further replies.

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,882
Reaction score
1,359
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?).
bk0dtio.png

9Wut5VT.png


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
857
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,882
Reaction score
1,359
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
857
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?
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,882
Reaction score
1,359
First Language
Portuguese - Br
Primarily Uses
RMMZ

Attachments

  • Eli_HelpWindows.js
    4.8 KB · Views: 3

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
857
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,882
Reaction score
1,359
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
8,267
Reaction score
5,444
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.

Latest Threads

Latest Posts

Latest Profile Posts

Made the "My Beating Mystery" board today:
3ENFLSC.png

in Grim Trigger episodes 3 & 4, the main characters play a Clue rip-off board game called "My Beating Mystery" (haha), so of course I had to draw the board for it. Can't decide if I wanna add blood or not
Jeez...
I finally decide, after several ppl asking me to, to create a gamethread about project M... And my internet craps out on me halfway through the process :(
making my first game is like trying to stuff all my experience with old games into one
so its slow and painful when i dont get it right... i bet the next game is gonna be finished earlier!
When you don't find any time to work... :kaocry:
First Ten Minutes of my Caretaker inspired game

Forum statistics

Threads
110,398
Messages
1,052,979
Members
143,458
Latest member
KyN19
Top