The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Tutorials and Eventing => Topic started by: mortexic on May 18, 2008, 06:10:35 PM

Title: $PLAYER_1 type variable for player names to use in message text?
Post by: mortexic on May 18, 2008, 06:10:35 PM
The game im working on allows custom player names. Is there a way to use something like "Hello There $PLAYER1" in message text to auto-insert players names?
Title: Re: $PLAYER_1 type variable for player names to use in message text?
Post by: DeathLock~ on May 18, 2008, 06:25:22 PM
If the RMVX has the same code as RMXP.

Posted wrong code, go lower for the correct one.
Title: Re: $PLAYER_1 type variable for player names to use in message text?
Post by: mortexic on May 18, 2008, 06:51:31 PM
Doesnt seem to work, what am I missing?

http://www.neasot.org/pub/ss1.jpg
Title: Re: $PLAYER_1 type variable for player names to use in message text?
Post by: DeathLock~ on May 18, 2008, 07:21:50 PM
Sorry about that.

Its suppose to be \n[X]. XD

Use \n[X], X = Actor ID in the database.

So, in the event you use that code for the name, and in the game it will show the name of the player.

Example:
\n[0] shows the name of the first member of the party.
\n[1] shows the name of the first actor in the database.
Title: Re: $PLAYER_1 type variable for player names to use in message text?
Post by: mortexic on May 19, 2008, 10:01:55 AM
The syntax is correct now, but I get a windows error popup window anytime the event is invoked.  :-\

The error is "Script 'Window_Message' line 218: NoMethodError occured. undefined method 'name' for nil:nilclass"

I tried with different combinations of numbers of players in party and all that. No luck.

Thoughts?
Title: Re: $PLAYER_1 type variable for player names to use in message text?
Post by: DeathLock~ on May 19, 2008, 02:12:35 PM
Are you using a custom message system script?
Title: Re: $PLAYER_1 type variable for player names to use in message text?
Post by: mortexic on May 20, 2008, 09:02:06 PM
Nope, I'm pretty "default".
Title: Re: $PLAYER_1 type variable for player names to use in message text?
Post by: DeathLock~ on May 21, 2008, 03:37:16 PM
Don't know, maybe you should copy all the data from your project into a new project.
Title: Re: $PLAYER_1 type variable for player names to use in message text?
Post by: Tsunokiette on May 23, 2008, 02:46:21 AM
Actually, it's the default script's fault. It doesn't include an option to use the 0.

To fix it, go to line 218 in Window_Message and replace it with the following -

    @text.gsub!(/\\N\[([0-9]+)\]/i) { if $1.to_i == 0
                                        $game_party.members[$1.to_i].name
                                      else
                                        $game_actors[$1.to_i].name
                                      end }