Replace Method Issue

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
854
First Language
English
Primarily Uses
RMMV
I have been editing the default Window_Status code, removing the actor parameters and equipment to open up an larger area for the actor profile. The stored profile text is passed through drawTextEx which uses the convertEscapeCharacters function. Now, convertEscapeCharacters should convert the new line escape codes I placed into the text, but it doesn't.


Here is the simple, two line dummy text which is stored in the profile :


Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n Quisque arcu quam, convallis rutrum neque id, cursus est.




[Console]


> typeof $gameActors.actor(1)._profile;
< "string"


Ok.


> $gameActors.actor(1)._profile;
< "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n Quisque arcu quam, convallis rutrum neque id, cursus est."


Ok.


> Window_Base.prototype.convertEscapeCharacters($gameActors.actor(1)._profile);
< "Lorem ipsum dolor sit amet, consectetur adipiscing elit.n Quisque arcu quam, convallis rutrum neque id, cursus est."


Wait, what? The function should be replacing '\n' with '\x1bn' which then is converted into a new line.


Window_Base.prototype.convertEscapeCharacters = function(text) {
//
// Replacement
text = text.replace(/\\/g, '\x1b');
//
//
text = text.replace(/\x1b\x1b/g, '\\');
text = text.replace(/\x1bV\[(\d+)\]/gi, function() {
return $gameVariables.value(parseInt(arguments[1]));
}.bind(this));
text = text.replace(/\x1bV\[(\d+)\]/gi, function() {
return $gameVariables.value(parseInt(arguments[1]));
}.bind(this));
text = text.replace(/\x1bN\[(\d+)\]/gi, function() {
return this.actorName(parseInt(arguments[1]));
}.bind(this));
text = text.replace(/\x1bP\[(\d+)\]/gi, function() {
return this.partyMemberName(parseInt(arguments[1]));
}.bind(this));
text = text.replace(/\x1bG/gi, TextManager.currencyUnit);
return text;
};








Why do you do this, function?
 
Last edited by a moderator:

DreamX

Veteran
Veteran
Joined
May 30, 2015
Messages
816
Reaction score
826
First Language
English
Primarily Uses
It looks like the actors json is saved by converting the \n to \\n in the profile descriptions.
 

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
854
First Language
English
Primarily Uses
RMMV
It looks like the actors json is saved by converting the \n to \\n in the profile descriptions.


Mmhmm ... but other escape codes are converted in the same way, yet those seem to work just fine.


\I[5]Suspendisse \C[5]egestas, velit sed\C[0] accumsan tincidunt, orci\nleo posuere ipsum, nec tristique tortor arcu eu ligula.


Each one works as it should except for the new line code.


EDIT: Ah, I guess the function is not looking for '\n' in textual form, but the actual ANSI newline character. Blah. I guess aliasing the convertEscapeCharacters to slip in a replace for '\n' is best, then. Brain is frazzled.
 
Last edited by a moderator:

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

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,045
Members
137,569
Latest member
Shtelsky
Top