Split by long Parameter

Hello 🙂


sry for my bad english!


I have a "Parameters" with this text "Hello, i'm a test text and i'm a loooooong text for testing the box."


* @param Description
* @desc test text
* @default Hello, i'm a test text and i'm a loooooong text for testing the box.



Code:
 var bpcpara = PluginManager.parameters("BPC_Difficulty");
 var txtcolord = String(bpcpara["Text Color Description"]);






so, i dont have a idea for Split the text.


i know i can to ths with that:


var names = bpcpara["Description"].split(",").filter(function(value) { return !!value; });




but i would change my text so:


Hello, i'm a test text and i'm a


loooooong text for testing the box.


How i can to this?


Mfg


Sajiki
If you want to automate this then you need to count the parameter's characters and then decide on a maximum amount of characters per line. Then you need to cut the parameter value off and break it into a new line at that point. Unfortunately if it's meant to have words, you also need to search for the nearest space character that's under the max character per line limit and then break it off their instead. Honestly it's a bit of a pain and it will involve a few different operations and probably some regex. 


OR, you could just impose this onto the user. Have them add their own line break where they want it by using a delimiting character and then just split your parameter on that special character. You are kind of already doing this with the split function you're using and a comma. 


The split function is part of the string object in JavaScript. It returns an array of items from the string and uses the delimiter you provided to design how to place each bit of text in the array. 


var names = "Bob,Sally,Joe,Mark";

var nameArray = names.split(",");

// nameArray is now an array like this: ["Bob","Sally","Joe","Mark"]


But I can't tell if that really helps you. You appear to want to add a new line to your text, correct? If it's just text in an alert box you can insert \n wherever you want the new line. If it's HTML text on the page, you would need to insert something that would create a break like a <br/> tag. If it's a message box in RMMV then you'd need to use whatever mechanism RMMV uses for new lines or whatever plugin you're using ... there's no telling. I'd really need more details on how you're using this text to help you. 
Thanks for answer 🙂


I have it done, your Split methode is a good idea.


i have give the Users breake the text with <br>.


Thanks for help 🙂

Original thread: https://forums.rpgmakerweb.com/threads/split-by-long-parameter.63705/