The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Tutorials and Eventing => Topic started by: Erk64 on June 03, 2007, 10:44:23 PM

Title: [RESOLVED] my name/variable problem
Post by: Erk64 on June 03, 2007, 10:44:23 PM
Okay. This one going to be fun. I am in the early stages of developing a game where you get to select a party or four members from about ten possible characters. It sounds goods, but I ran into a problem as soon as I came across my fist major cutscene. Because I have no way of predicting what characters the player has in their party, it makes writing the dialogue extremely difficult.

Here's what I need to (hopefully) fix this. Is there any way to assign a character's name to a variable? That way, I can make it so the first character the player chooses to their party will be assigned to variable 1, and the second to 2, and so one. That way, when I come to dialogue scenes, I can just type \v[001] or whatever instead of typing the character's name.

Sorry if this is confusing. Basically, can you assign a name to a variable. And if you think you have a good understanding of my situation, do you see any other possible solutions (no scripting, please, unless you can direct me to a script). Thanks in advance.
Title: Re: my name/variable problem
Post by: Polraudio on June 03, 2007, 11:27:41 PM
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fimg443.imageshack.us%2Fimg443%2F9666%2F001zc5.png&hash=770ac6d67675b8ca38bf3a9e68d616141ff7aedd)
you would use \N[1] to display yhe 1st chars name and \N[2] for the secont
Is this what you needed?
if this dont help you just let me know
Title: Re: my name/variable problem
Post by: modern algebra on June 04, 2007, 02:32:02 AM
And if you don't need each character to say unique things all the time, you could just set variables to the ID of the heroes in your party.

I.e.

Variable 1 = 1st hero in party ID
Variable 2 = 2nd hero in party ID
etc...


And then to display name, write \n[\v[1]] for lead party member, \n[\v[2]] for second party member.


If you want them to say unique things, then do as Polraudio said.
Title: Re: my name/variable problem
Post by: Erk64 on June 04, 2007, 04:48:25 AM
Okay, that should work. Thanks to both of you, because I willl probably do a little of each, depending on the importance of the scene.

But my question now, is how do you assign a character's ID to a variable? (I'm using RMXP, if I hadn't said so already.)


EDIT: Ah, nevermind. It assigns them automatically. I should have paid more attention to Seamus' post. Seamus got the explanation right, but the coding wrong, however. It should be:  \n[1] and not \n[\v[1]]. Polraudio was right about that part. But you two both helped me out in the end, so thanks!
Title: Re: my name/variable problem [resolved]
Post by: modern algebra on June 04, 2007, 06:31:29 AM
eh? It doesn't do it automatically. \n[1] will always display the name of the first hero in the databse, \n[2] the second, etc...

\n[\v[1]] will display the name of the hero who's ID is represented by Variable 1.

So, if Variable 1 = 4, then \n[\v[1]] will display the name of the fourth hero in the database.

What I was suggesting is that as each member joins your party, then you assign a variable to their ID. So, you choose your first character, who, for example is the 3rd hero in the database, you assign variable 1 to 3. Second hero is actor 5, you assign: Variable 2 = 5

Then, \n[\v[1]] will give the name of the first hero in your party

\n[\v[2]] would give the name of the second hero in your party, whereas \n[1] would give the name of first hero in DB and \n[2] would give name of 2nd hero in DB
Title: Re: my name/variable problem [not-so-resolved]
Post by: Erk64 on June 04, 2007, 03:54:50 PM
Ooooohhh. Okay. But I still need to know how to assign a particular chararacter's ID to a variable.
Title: Re: my name/variable problem [not-so-resolved]
Post by: modern algebra on June 04, 2007, 05:06:36 PM
Oh, well you can do it like this:

Manually:

I will be using Variables 1-4 to hold the party member ID's. And I will be using Variable 5 to keep track of the size of the party. Note that <new character> is just the character in that event who you are adding. So, if it is Aluxes/Arshes, his ID is 1, so <new character> is replaced by Aluxes/Arshes, and <new character ID> is replaced with 1. If it is Basil, and his ID is 2, then <new character> is replaced by Basil and <new character ID> by 2, etc...

So, in the event where you are adding the party member, put this:

Conditional Branch: Variable [005: Party Size] <= 4
   Change Party: + <new character>
   Control Variables: Variable [005: Party Size] + 1
   Conditional Branch: Variable [005: Party Size] = 1
       Control Variables: Variable [001: Party Member 1 ID] = <new character ID>
   Else
      Conditional Branch: Variable [005:: Part Size] = 2
        Control Variables: Variable [001: Party Member 2 ID] = <new character ID>
      Else
         Conditional Branch: Variable [005: Party Size] = 3
             Control Variables: Variable [001: Party Member 3 ID] = <new character ID>
         Else
             Conditional Branch: Variable [005: Party Size] = 4
                 Control Variables: Variable [001: Party Member 4 ID] = <new character ID>
             Branch End
         Branch End
      Branch End
   Branch End
Else
   Text: Your party is full, and you cannot add another person.
Branch End

I believe that would work. I would think there would be an easier way, but I can't think of it right now. Just put that in each event that you want to give you a party member with the values <new character> and <new character ID> replaced appropriately.
         
Title: Re: my name/variable problem [not-so-resolved]
Post by: Erk64 on June 04, 2007, 06:59:28 PM
That doesn't work. All you are really doing is assigning a number to a variable, but you never really assing the variable to the character's name.
Title: Re: my name/variable problem [not-so-resolved]
Post by: modern algebra on June 04, 2007, 07:03:43 PM
Essentially, you are though, since \n[\v[X]] will then display that character's name, because \v[X] is the character ID. Basically, if a character ID is 5, then that number is assigned to \v[X]. Thus \n[\v[X]] is the same as \n[5], which is the character's name. So, if you are using variable 1 to hold the ID of actor 7, then \n[\v[1]] is equivalent to \n[7], which is the "variable" (you could say) which contains that actor's name.
Title: Re: my name/variable problem [not-so-resolved]
Post by: Erk64 on June 04, 2007, 07:14:37 PM
I don't know...I tried it but it didn't work. However, I looked under that sticky thread at the top of the tut page, "Blizzard's Little Tricks," and there is a solution posted there. You use the call script event and type in:

$game_variables[1]=
$game_party.actors[0].name

That will assign the first actor in your party to the first variable, for instance. I appreciate your help though.
Title: Re: my name/variable problem [resolved]
Post by: modern algebra on June 04, 2007, 08:10:46 PM
That's undoubtedly an easier way to do it. But, just so you know that my way does in fact work, I took 5 minutes and made a demo.
Title: Re: [RESOLVED] my name/variable problem
Post by: Erk64 on June 06, 2007, 01:27:41 AM
Oh. Well, in that case, I stand corrected.