(RMMV) How to put line breaks in a variable string?

Michael Primo

Villager
Member
Joined
Apr 21, 2017
Messages
17
Reaction score
12
First Language
Italian
Primarily Uses
RMMV
Hello guys,

My problem is this:

I want to use a plugin called RS_InputDialog by Biud436 for writing a 160 character string and show in a message.

The problem is this: the 160 character string is too huge for the window and I can't disable wordwrapping on variables!

What must I do?

Thanks for your time,

Michael Primo
 

Michael Primo

Villager
Member
Joined
Apr 21, 2017
Messages
17
Reaction score
12
First Language
Italian
Primarily Uses
RMMV
Add a "\n".
Hello!

I tried that,but it only works if I put some text on the message window. I need the line breaks inside the string or other things I don't know because firstly stamp the variable and after the \n. I used \v[1]\n on the message box but it doesn't work,it only show the fully variable wordwrapped.

Thanks!
 

Gamefall Team

Nebula Games Leader
Veteran
Joined
Jan 10, 2017
Messages
345
Reaction score
440
First Language
Italian
Primarily Uses
RMMV
Have you tried to add two "\" instead of one?
Ex. "\\n"
 

Gamefall Team

Nebula Games Leader
Veteran
Joined
Jan 10, 2017
Messages
345
Reaction score
440
First Language
Italian
Primarily Uses
RMMV
Oh, I misunderstood the question, then. Mmm... Well the simple \n, I think, change line for all the placed text in the var. Have you tried to add the \n in the var itself? I mean, in the text storedin var. Or you probably need a way to calculate the the text height in relation to the window width.
 

Michael Primo

Villager
Member
Joined
Apr 21, 2017
Messages
17
Reaction score
12
First Language
Italian
Primarily Uses
RMMV
Oh, I misunderstood the question, then. Mmm... Well the simple \n, I think, change line for all the placed text in the var. Have you tried to add the \n in the var itself? I mean, in the text storedin var. Or you probably need a way to calculate the the text height in relation to the window width.
Howdy!

I tried even that.

About the \n inside the string I Need to do automatically instead manually because when a person insert the 160 character he do all in-game so I mustn't edit later the string,because I won't make that string.

About the text width I can do that thanks to the plugin,but I can show 70 characters per line,80 if thanks to YEP Message Core I reduce the font size.

With the actually plugin (Biud436's RS_InputDialog) I can write only a large line.

I tried even the Mr Trivel solution but It seems which I can do only a Short line,without making new lines.

Alternative Question: what plugin can allow the user to input text,store in different variables and with multiple lines to edit (like the default 4 of the window)?

Thanks for your time!
 

Gamefall Team

Nebula Games Leader
Veteran
Joined
Jan 10, 2017
Messages
345
Reaction score
440
First Language
Italian
Primarily Uses
RMMV
Well, I don't know if there is a plugin like that out here. I know the one made by biud and If a remember correctly Quxios has made something related to the input. Probably a way to solve this is to write a function that loop the text inserted by the user an when the text width is higher than the window width, push a line break in there.
 

Michael Primo

Villager
Member
Joined
Apr 21, 2017
Messages
17
Reaction score
12
First Language
Italian
Primarily Uses
RMMV
Well, I don't know if there is a plugin like that out here. I know the one made by biud and If a remember correctly Quxios has made something related to the input. Probably a way to solve this is to write a function that loop the text inserted by the user an when the text width is higher than the window width, push a line break in there.
I wanted to try the Quxios solution but I saw 404 in Github and the quasixi.com site closed,so...I don't know how can I find the plugin.

I thought a replace solution with a script After inserting the line,but maybe I was doing mistakes in doing It.

Can you show me a Example?

Thanks so much!
 

Gamefall Team

Nebula Games Leader
Veteran
Joined
Jan 10, 2017
Messages
345
Reaction score
440
First Language
Italian
Primarily Uses
RMMV
Have you tried to find him on github?
About an example, you can try to add something like that, but should be tested and implemented on the correct place, I think you should add this feature in the plugin itself:
Code:
Example.prototype.textWrap = function() {
        var input = $gameVariables._data[BIUDSTOREDVAR];
        var text = input.replace(/(\r\n|\n|\r)/gm, "").split(' ').map(function(space) { return space.trim(); });
        var newText = '';
        var lw = 0;
        for(var i = 0; i < text.length; i++) {
            lw += i == 0 ? this.textWidth(text[i]) : this.textWidth(' ' + text[i]);
            if(lw >= WINDOWWIDTH) {
                newText += i == 0 ? text[i] : '\n' + text[i];
                lw = 0;
            }
            else newText += i == 0 ? text[i] : ' ' + text[i];
        }
        return newText;
    };
This an example how I would write a text wrap code, but depends on the situation itself.
 

Michael Primo

Villager
Member
Joined
Apr 21, 2017
Messages
17
Reaction score
12
First Language
Italian
Primarily Uses
RMMV
Have you tried to find him on github?
About an example, you can try to add something like that, but should be tested and implemented on the correct place, I think you should add this feature in the plugin itself:
Code:
Example.prototype.textWrap = function() {
        var input = $gameVariables._data[BIUDSTOREDVAR];
        var text = input.replace(/(\r\n|\n|\r)/gm, "").split(' ').map(function(space) { return space.trim(); });
        var newText = '';
        var lw = 0;
        for(var i = 0; i < text.length; i++) {
            lw += i == 0 ? this.textWidth(text[i]) : this.textWidth(' ' + text[i]);
            if(lw >= WINDOWWIDTH) {
                newText += i == 0 ? text[i] : '\n' + text[i];
                lw = 0;
            }
            else newText += i == 0 ? text[i] : ' ' + text[i];
        }
        return newText;
    };
This an example how I would write a text wrap code, but depends on the situation itself.
Thanks so much! I'll try it today! ^_^
 

Michael Primo

Villager
Member
Joined
Apr 21, 2017
Messages
17
Reaction score
12
First Language
Italian
Primarily Uses
RMMV
Have you tried to find him on github?
About an example, you can try to add something like that, but should be tested and implemented on the correct place, I think you should add this feature in the plugin itself:
Code:
Example.prototype.textWrap = function() {
        var input = $gameVariables._data[BIUDSTOREDVAR];
        var text = input.replace(/(\r\n|\n|\r)/gm, "").split(' ').map(function(space) { return space.trim(); });
        var newText = '';
        var lw = 0;
        for(var i = 0; i < text.length; i++) {
            lw += i == 0 ? this.textWidth(text[i]) : this.textWidth(' ' + text[i]);
            if(lw >= WINDOWWIDTH) {
                newText += i == 0 ? text[i] : '\n' + text[i];
                lw = 0;
            }
            else newText += i == 0 ? text[i] : ' ' + text[i];
        }
        return newText;
    };
This an example how I would write a text wrap code, but depends on the situation itself.
Hello!

I tried to insert the snippet in this way.


it doesn't work.

I tried to go on Quxios Github but I doesn't see the repo of Quasi Input,it seems he deleted it. I don't know.

Thanks for your time!
 

Gamefall Team

Nebula Games Leader
Veteran
Joined
Jan 10, 2017
Messages
345
Reaction score
440
First Language
Italian
Primarily Uses
RMMV
Try this way, before the Input Clear and under the if statment on line 518, add this one to reset the var like that:
Code:
$gameVariables.setValue(RS.InputDialog.Params.variableID, this.textWrap())
 

Michael Primo

Villager
Member
Joined
Apr 21, 2017
Messages
17
Reaction score
12
First Language
Italian
Primarily Uses
RMMV
Try this way, before the Input Clear and under the if statment on line 518, add this one to reset the var like that:
Code:
$gameVariables.setValue(RS.InputDialog.Params.variableID, this.textWrap())

I tried to insert the things in this way,

I have a TypeError: undefined is not a function.

For this attempts I am using the demo of RS_InputDialog so I don't think is a problem of my game or a script I inserted.

Thank you for your support and your fast reply!
 

Gamefall Team

Nebula Games Leader
Veteran
Joined
Jan 10, 2017
Messages
345
Reaction score
440
First Language
Italian
Primarily Uses
RMMV
Oh the problem is about the text width. I didn't notice you have inserted in a Scene. The error is related to the fact that in Scene_InputDialog and in its constructor there is not the text width function that is inserted in the windows classes. Probably, you can try to proceed this way, add this code:

Code:
Scene_InputDialog.prototype.createDummy = function() {
this._dummyWindow = new Window_Base(0 ,0, 0, 0);
this.addWindow(this._dummyWindow);
}
Add to the create method of the Scene_InputDialog the function i have write as: "this.createDummy())"
Next, change the this.textWidth() to this._dummyWindow.textWidth()
 

Michael Primo

Villager
Member
Joined
Apr 21, 2017
Messages
17
Reaction score
12
First Language
Italian
Primarily Uses
RMMV

I inserted it in this way,but...it doesn't show the input dialog,and even if I manually insert the variable string the word wrap from the script doesn't work.

Sorry if I am consuming your time...
 

Gamefall Team

Nebula Games Leader
Veteran
Joined
Jan 10, 2017
Messages
345
Reaction score
440
First Language
Italian
Primarily Uses
RMMV
No problem, we're to help ;)
You have misunderstood my words :)
the create dummy should be inserted in the Scene_InputDialog.prototype.create, not in the okResult.
In the ok result you should replace the set value for the variable: $gameVariables etc..
 

Michael Primo

Villager
Member
Joined
Apr 21, 2017
Messages
17
Reaction score
12
First Language
Italian
Primarily Uses
RMMV
No problem, we're to help ;)
You have misunderstood my words :)
the create dummy should be inserted in the Scene_InputDialog.prototype.create, not in the okResult.
In the ok result you should replace the set value for the variable: $gameVariables etc..
I tried to put the this.createDummy(); on the first line of the Scene_InputDialog.prototype.textWrap function.

Now I have a TypeError: Cannot read property "AddChild" of undefined. I don't know why.

Thanks!
 

Gamefall Team

Nebula Games Leader
Veteran
Joined
Jan 10, 2017
Messages
345
Reaction score
440
First Language
Italian
Primarily Uses
RMMV
Try to change the constructor of the scene from Scene_Base to Scene_MenuBase :)
 

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

Latest Threads

Latest Profile Posts

Managed to find a way to hang a bed cover over my window. So no more being toasted alive in the afternoon!:kaoswt2:
So, uh, has anyone tried buying any resources from KokoroReflections? Because I've been looking for a 'buy' button on the site for like 10 minutes now and can't find one.
Any also thought it's too cringy to put the word "and you" in your credit as a special thanks?
Cause that's what I thought...
Everyone in the US right now: Please stay safe.
Symphony Celestia: Prophecy of the Falling Stars RPG Maker music pack WIP. Symphony Celestia is a new series that focuses on symphonic and orchestrated music to tell a story. Each story will include compositions that make up that story from beginning to end. Themes include: Battles, adventures, character themes, etc. Below is a video preview to the first story.

Forum statistics

Threads
97,980
Messages
948,318
Members
129,242
Latest member
Kelevra069
Top