The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Tutorials and Eventing => Topic started by: meiko_suzuki on December 29, 2010, 04:43:18 AM

Title: [Resolved]Storing a player's name in a variable?
Post by: meiko_suzuki on December 29, 2010, 04:43:18 AM
Hey, I'm trying to figure out how I can store a character's name (once the player enters it) into a variable...then apply that variable name to a different character.

Basically, for my game I have a couple of different classes. But the way I have to do it is each class gets a character, so as not to eff up the levels and such.

Problem is, though, that their names will never be the same as the original character. Due to the player having the ability to enter any name they want for the original. >_<

Can anyone help me out? (If this belongs in scripting,put it there =D)
Title: Re: Storing a player's name in a variable?
Post by: cozziekuns on December 29, 2010, 05:24:04 AM
Use the event "Call Script", and use:

Code: [Select]
$game_variables[x] = $game_actors[y].name

X is the variable which you want to store the actors name. Y is the place that the actor is stored in the database, which can be found to the right of the characters name in the actors sidebar.
Title: Re: Storing a player's name in a variable?
Post by: meiko_suzuki on December 29, 2010, 04:29:42 PM
._.' When I try to apply it in game, I get a NoMethodError...undefined method 'name' for [1]:Array

This is what I put in the script:
$game_variables[8] = $game_actors[001].name

...scripting newb is n00b? XD

And if you can help me figure out how to apply that variable to the other characters I will love you for life XD
Title: Re: Storing a player's name in a variable?
Post by: modern algebra on December 29, 2010, 05:33:06 PM
It has to be all on one line. Also, don't bother with the 0s before the 1

Anyway do it like this:
Code: [Select]
a = $game_actors[1]
$game_variables[8] = a.name

I recommend that you clear it back to 0 once you are done with it, as otherwise you will get errors if you try to operate on it accidentally.
Title: Re: Storing a player's name in a variable?
Post by: meiko_suzuki on December 29, 2010, 05:45:02 PM
Ah, I got it. So, let's say I wanted Actor 10 to have the same name as Actor 1. How would I go about that?  :D

Thanks for your patience XD
Title: Re: Storing a player's name in a variable?
Post by: modern algebra on December 29, 2010, 05:51:04 PM
Code: [Select]
a1 = $game_actors[1].name
$game_actors[10].name = a1
Title: Re: Storing a player's name in a variable?
Post by: meiko_suzuki on December 29, 2010, 06:00:16 PM
THANK YOU SO MUCH! <3 <3 <3

You, good sir, win the internet.
Title: Re: Storing a player's name in a variable?
Post by: Zeriab on December 29, 2010, 11:25:15 PM
(...) Also, don't bother with the 0s before the 1 (...)

Lemme elaborate a bit on this because there is a functional difference in that having any leading 0s causes the number to be parsed with base 8 rather than base 10. I.e.

01 == 1
07 == 7
08 and 09 gives an error
010 == 8
011 == 9
012 == 10
...

*hugs*