Main Menu

[Resolved]Storing a player's name in a variable?

Started by meiko_suzuki, December 29, 2010, 04:43:18 AM

0 Members and 1 Guest are viewing this topic.

meiko_suzuki

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)
Game in the works:
The Adventures of the Generic Hero(ine)
Gameplay: 20%
Mapping: 10%
Characters: 80%
Events: 30%
Ways to Die: 30%
Cliches: 65/192
?? ??
PROFIT!

cozziekuns

Use the event "Call Script", and use:


$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.

meiko_suzuki

#2
._.' 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
Game in the works:
The Adventures of the Generic Hero(ine)
Gameplay: 20%
Mapping: 10%
Characters: 80%
Events: 30%
Ways to Die: 30%
Cliches: 65/192
?? ??
PROFIT!

modern algebra

It has to be all on one line. Also, don't bother with the 0s before the 1

Anyway do it like this:

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.

meiko_suzuki

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
Game in the works:
The Adventures of the Generic Hero(ine)
Gameplay: 20%
Mapping: 10%
Characters: 80%
Events: 30%
Ways to Die: 30%
Cliches: 65/192
?? ??
PROFIT!

modern algebra


a1 = $game_actors[1].name
$game_actors[10].name = a1

meiko_suzuki

THANK YOU SO MUCH! <3 <3 <3

You, good sir, win the internet.
Game in the works:
The Adventures of the Generic Hero(ine)
Gameplay: 20%
Mapping: 10%
Characters: 80%
Events: 30%
Ways to Die: 30%
Cliches: 65/192
?? ??
PROFIT!

Zeriab

Quote from: modern algebra on December 29, 2010, 05:33:06 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*