Call an actor's name depending on which party slot they are in?

Need to have an NPC mention each name of each character in the party, in the same order they are in.
Maybe through storing each chara in a variable? Then how to "translate" it into the character's name?

I'm OK with using scripts to achieve it, if there's need to do so.
\P[1] \P[2] \P[3] \P[4]

You know you can hover your mouse over the text area of the Text box and wait a bit, and it'll show you a list of all the escape codes you can use?
Question related to that: What script does the program run in order to do that?

EDIT: Never mind, found out that one can store the name as a variable when using $gameActors.actor(n).name() , where n is the number of the actor that needs its name stored. Thanks!
Shaz' method works with the default engine, you wont even need to save the name into variables...
Sorry, I tend to like having info I may need later into variables... it's a bit of a weirdness of mine. Sorry if I came off as intensely rude.
In this case, check out rpg_windows.js and look for Window_Base.prototype.convertEscapeCharacters - that's what handles the substitution of those codes into actor names in the message window.

However, for most of the event commands, if you want to see how they work behind the scenes, rpg_objects.js is the place to go, and look for Game_Interpreter.prototype.command<numbers> as there is one for every event command, and the comment immediately above is the same as the command button text (so command101 has the comment Show Text above it). And in that case, you could just do a search in that file for the text you see on the command button, and in most instances it'll take you directly to the code that handles it.

Have fun exploring - that's how I learned pretty much everything I know about scripting for RPG Maker.

Original thread: https://forums.rpgmakerweb.com/threads/call-an-actors-name-depending-on-which-party-slot-they-are-in.111749/