Status
Not open for further replies.

sutorumie

I'm a whimsical girl.
Veteran
Joined
Apr 26, 2014
Messages
30
Reaction score
1
First Language
English
Primarily Uses
RMMV
I'm attempting to make random NPC dialogue by setting up a variable to store the dialogue into, then defining the variable as a text string which is randomly selected via condition branch / rng variable. However, when I want to make the NPC say the player character's name, it instead displays it as just "N[1]". I tried using \\N[1] in the string instead of \N[1] but this just makes "\N[1]" display in the text box. \n works just fine for linebreaks though, which I found out by accident lol

Is there a way around this? \\\N[1] doesn't work either.


tumblr_pht6a5Mws61qi7tzho1_r1_1280.png


I wasn't able to find anything about this by googling or searching these forums, maybe I'm using the wrong terms (or maybe it's my ADD making it hard to read 100% of the things I see) but I can't seem to find anything even remotely close to what I'm looking for
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,640
Reaction score
8,647
First Language
Indonesian
Primarily Uses
RMVXA
First, your text style of using red is not necessary, it hurts in dark mode. Besides, not sure if you're even allowed to use red/blue text color in your text bcz, well, rules.

Second, try to add double slash instead. Like \\N[12].
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,575
Reaction score
1,622
First Language
Spanish
Primarily Uses
RMVXA
I believe the reason why it's not working, is because when you order a display of \v[X], the result of \v[X] (actually a string with an escape character in it), is not further processed as *a string with an escape character in it*
it is presented as "a final result contained in this variable". (the final result being, a string, with an escape character, which should be processed, but isn't)
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,159
Reaction score
10,751
First Language
Czech
Primarily Uses
RMMV
I don't think you can put \n[1] inside a variable and display it like that, since message window doesn't allow compound tags (meaning you cannot have a tag inside a tag). Under normal circumstances \\N[1] (execution via code for example) would have worked, but not inside a tag. The reason why \n works as a new line is simply it being a thing of Javascript.

Btw. @TheoAllen red and blue are alright in the OP. In replies they would not be alright. Nevertheless, I agree that this kind of red is too dark.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,640
Reaction score
8,647
First Language
Indonesian
Primarily Uses
RMVXA
@Poryg ya know, it's okay to use it for OP formatting like a game thread. But I'm afraid this kind of stylizing will be carried into replies for a sake of being stylish (and she did). I know I did too in the long past.

As for being an actual topic, those two explanations make sense, and I missed that in fact, you did it urself and didn't work, which again I missed to read it because of the color.
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,575
Reaction score
1,622
First Language
Spanish
Primarily Uses
RMVXA
I don't think you can put \n[1] inside a variable and display it like that, since message window doesn't allow compound tags (meaning you cannot have a tag inside a tag)
you can't, because the process delivers what's in that variable and exits without double-checking, but you could, if you took the result and feed it back to the same process in order to catch that nested tag.

all I have is Ace at hand, this is a shot in the dark, but hopefully you'll get the idea.
Code:
def convert_escape_characters(text)
    result = text.to_s.clone
    result.gsub!(/\\/)            { "\e" }
    result.gsub!(/\e\e/)          { "\\" }
    result.gsub!(/\eV\[(\d+)\]/i) { $game_variables[$1.to_i] }
    result.gsub!(/\eN\[(\d+)\]/i) { actor_name($1.to_i) }
    result.gsub!(/\eP\[(\d+)\]/i) { party_member_name($1.to_i) }
    result.gsub!(/\eG/i)          { Vocab::currency_unit }
    result
  end

Code:
    result.gsub!(/\eV\[(\d+)\]/i) { $game_variables[$1.to_i] }

   result.gsub!(/\eV\[(\d+)\]/i) { convert_escape_characters($1)}

just as \n triggers a call to actor_name(result_of_operation), set \v to trigger a convert_escape_characters(result_of_operation), with "convert_escape_characters()" being in fact "ourselves", from the method's own point of view.
in essence, a feedback.
 

sutorumie

I'm a whimsical girl.
Veteran
Joined
Apr 26, 2014
Messages
30
Reaction score
1
First Language
English
Primarily Uses
RMMV
@gstv87 So I went through rpg_windows.js looking for something similar to those codes you posted, and I found the section on escape codes, but it wasn't quite formatted similarly enough for me to have any idea what to do with it. I started looking at the codes below to see if maybe there was something defined there, and I found this:

Code:
case '\x1b':

        this.processEscapeCharacter(this.obtainEscapeCode(textState), textState);
        break;

So I thought to myself... maybe I can use that?

tumblr_pht6a5Mws61qi7tzho1_r2_1280.png


Annnnd, voila!

tumblr_pht6a5Mws61qi7tzho2_r2_1280.png


Perfect! Thanks for pointing me in the right direction c:
 

mlogan

Global Moderators
Global Mod
Joined
Mar 18, 2012
Messages
16,360
Reaction score
9,060
First Language
English
Primarily Uses
RMMV

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

5 months and no progression at all, i love me.
1.6 update incoming with quality breakthrough! :kaoluv:

1643254634071.png
I might try the mechanical bull at the fair on Friday... for one of the challenges, if you stay on for two minutes, you win $200. I might give that a try and see if I win--I'm pretty good at holding on to things.
Remaking a more streamlined version of my Remote Move map skill in MZ, just one switch and one variable to handle everything. If you seen the Move skill in Golden Sun before, moving far away items with your mind is pretty cool

MZtestRemoteMove.gif
I don't want to brag or anything but I was entertaining a woman the other night. I told her jokes while she bandaged my foot.

Forum statistics

Threads
118,735
Messages
1,118,359
Members
155,895
Latest member
Flike1963
Top