Chat Mapper – Getting Fancy

We’ve covered the basics of integrating Chat Mapper into RPG Maker, now I want to cover some possible synergies. Specifically, we’re going to take a look at how to use some features of Modern Algebra’s messaging script and Yanfly’s messaging script. I’ve talked about both previously, check out the posts here (MA) and here (Yanfly). This technique will work with most other scripts which take in-message codes and do something with them.

Name Plates

Around line 147 of the dialogue parser, you’ll find this:

if actor != nil && actor.name != ''
  $game_message.face_name = actor.name
else
  $game_message.face_name = ''

This code sets the face name, but it’s also an important question to ask: is there an actor? If so, what’s their name? Once we know this, we can set it up so that every game message called which has an actor name associated with it in Chat Mapper will also add a nameplate as created by either MA or Yanfly.

Before the else, we’ll want to put the following line for now:

strings[0] = strings[0]

Sounds stupid, I know, but we’re going to build on it. Suppose you’re using Modern Algebra’s script. If you look up what MA tells us about his script, you’ll see that adding something like

\nb{Katarina}

Will make it so that a name plate with “Katarina” will accompany that particular dialogue box. We can add the same to all of our code. So in that very silly line, let’s add “actor.name”

strings[0] = "\\nb{#{actor.name}}" + strings[0]

Yeah, that looks a little different than what MA instructed us to do – why?

First, any \s need to be doubled. \ indicates an escaped character – it tells the program “hey don’t print this part, do something else with it.” The problem is, we need the \ in the game message for RPG Maker (and Modern Algebra’s script) to know what to do. Using just one \ would fail to put anything in the game. If we really mean \, we need to use \\ – that tells the computer “hey, print one \.”

Second, we’re using actor.name with some weird symbols around it. In Ruby, #{stuff} converts that stuff into a string. Here, we’re converting the actor’s name into a string. So if actor name was Katarina, it would read \\nb{Katarina}. But since we don’t know ahead of time what the actor’s name is, using actor.name will work in all circumstances. Remember, this will only apply if the actor has a name; if he or she doesn’t, we’ll skip to after the else.

We can do the same with Yanfly’s Ace Message System. \n<name> is the in-message code, so:

strings[0] = "\\n<#{actor.name}>" + strings[0]

is what we add before the else.

Going Further

You can use anything that the message system you’re using includes. Modern Algebra uses \fit to make the text box fit, so:

strings[0] = "\\nb{#{actor.name}}" + "\\fit" + strings[0]

Yanfly uses \fb to make the font bold, so:

strings[0] = "\\n<#{actor.name}>" + "\\fb" + strings[0]

Just remember to use \\ instead of \, and you’ll be fine! Remember, these changes to the parser will change all of the dialogue coming out of Chat Mapper which has an actor associated with it, and none of the dialogue you’ve hard coded in RPG Maker. If you want to change all of the dialogue coming out of Chat Mapper regardless of whether there’s an actor, you’ll need to make your changes outside of the if/else statement we identified above.

Enoy!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s