[RMVX ACE] A WAY TO SET CONDITIONAL BRANCHES FROM AN ACTORID STORED IN A VARIABLE?
Posts
Pages:
1
Halp pls. The entirity of my game may rest on this.
My game has actors that I can't specify. Some of them are created via script and assigned an ActorID, so I can't tell which actor is which.
Boy was I thrilled to find out I could find out their ActorID's via Variable>Game Data>Party Member's ActorID.
But then I realized that I didn't know how to create Conditional Branches drawing from this variable.
I wanted to to do things like... if the party member was left in town then I could call up the conditional branch to change the sprite of the event depending on what class it was, or be able to add stats to this Actor through events.
I thought it'd be something like... I don't know,
I doubt the double square brackets would work huh...
Is there a way to call events for an actor via actorID stored in variable?
I have plenty of other questions to ask
but I probably should be spacing out my questions since I've been posting in every single other RPGMaker forum for help.
Aaaaaah... I really shouldn't have done this idea for IGMC without a programmer...
My game has actors that I can't specify. Some of them are created via script and assigned an ActorID, so I can't tell which actor is which.
Boy was I thrilled to find out I could find out their ActorID's via Variable>Game Data>Party Member's ActorID.
But then I realized that I didn't know how to create Conditional Branches drawing from this variable.
I wanted to to do things like... if the party member was left in town then I could call up the conditional branch to change the sprite of the event depending on what class it was, or be able to add stats to this Actor through events.
I thought it'd be something like... I don't know,
author=My guess?
$game_actors[$game_variable [61] ].add_param(1, 1)
I doubt the double square brackets would work huh...
Is there a way to call events for an actor via actorID stored in variable?
I have plenty of other questions to ask
author=Wrecking my brainHow to make critical rate rise when MP is lower
How to make HP fall like Poison when MP is 0
How to set a condition to check a stat of any actor is above a certain amount
but I probably should be spacing out my questions since I've been posting in every single other RPGMaker forum for help.
Aaaaaah... I really shouldn't have done this idea for IGMC without a programmer...
Hi Nivlacart,
The double brackets will work. Give it a shot.
This is unrelated, but I'm going to leave some tips here which I wish I'd known around the time I was just finding out that those double brackets will work. These tips are meant for people who are scouring this message board for more info:
You can also reference an array element nested inside multiple arrays by leaving a train of brackets, like this:
@my_huge_array[3][2][0][8] = "I'm a string inside the eighth element of the zeroth element of the second element of the third element of @my_huge_array."
You can also use a backslash to continue a line after a line break. Normally, in Ruby, a carriage return will mean the end of the line. but a backslash will concatenate the next line onto the current one.
my_string = "Even though this string exists on three " \
"lines, Ruby will treat it as a single string, thanks " \
"to the backslashes."
A semicolon does the opposite, creating a new line where there's no carriage return. This can make for some space-saving code:
HP = 30 ; MP = 25 ; STR = 12 ; DEF = 8 ; INT = 4 ; DEX = 8
And the final tip which was crucial to my understanding of Ruby and object-oriented programming: When you create a new instance of a class, its method called "initialize", if it exists, will run automatically.
The double brackets will work. Give it a shot.
This is unrelated, but I'm going to leave some tips here which I wish I'd known around the time I was just finding out that those double brackets will work. These tips are meant for people who are scouring this message board for more info:
You can also reference an array element nested inside multiple arrays by leaving a train of brackets, like this:
@my_huge_array[3][2][0][8] = "I'm a string inside the eighth element of the zeroth element of the second element of the third element of @my_huge_array."
You can also use a backslash to continue a line after a line break. Normally, in Ruby, a carriage return will mean the end of the line. but a backslash will concatenate the next line onto the current one.
my_string = "Even though this string exists on three " \
"lines, Ruby will treat it as a single string, thanks " \
"to the backslashes."
A semicolon does the opposite, creating a new line where there's no carriage return. This can make for some space-saving code:
HP = 30 ; MP = 25 ; STR = 12 ; DEF = 8 ; INT = 4 ; DEX = 8
And the final tip which was crucial to my understanding of Ruby and object-oriented programming: When you create a new instance of a class, its method called "initialize", if it exists, will run automatically.
Oh, what, really?
I thought it wouldn't because I tried something like that to make a Textbox speak the character's name but it didn't show...
Wait... I'm not supposed to use $game_variable in textboxes, am I?
Arrays sound handy, what do they do?
I thought it wouldn't because I tried something like that to make a Textbox speak the character's name but it didn't show...
Wait... I'm not supposed to use $game_variable in textboxes, am I?
Arrays sound handy, what do they do?
I forget what the code is in modern RPG Makers, but in 2003, you could display a variable by typing (backslash)v[(the variable number)] when you're entering the text. Then, when the text is displayed, whatever's stored in the variable shows in the text instead of the \v[(variable number)]. I'm sure that functionality is still in RPG Maker VX Ace, it might even be the same thing.
However, you're right, in that the text box can't do complicated script parsing. So "$game_actors[$game_variables[61]]" wouldn't mean anything inside of a text box.
You would have to do that using a little Script entry. Alright, I'm gonna suggest something radical... Try this:
From the event commands, open a Script. Inside the little Script window, type:
"that_actors_name = $game_actors[$game_variables[61]].params(1,1)" (Or wherever the name is stored, or whatever data you want)
Then, type this:
"$game_variables[62] = that_actors_name" (Or use whichever variable number you want, if not 62)
Now, even though we usually only store numbers in $game_variables, we're storing a string. Now, when you call that data using "\v[62]" inside of a text box, the name might show up. I'm not sure if it will, you'd have to test it.
As for arrays, they're just a handy way of organizing data. For example, $game_variables is an array of 9999 variables. So when you type "$game_variables[34]", for example, you're referencing whatever's in the 34th space of the $game_variables group. Traditionally, that space is called an element or index. You can put ANYthing in there. The RPG Maker interface typically restricts you to putting a number in $game_variables, but it can really hold anything.
However, you're right, in that the text box can't do complicated script parsing. So "$game_actors[$game_variables[61]]" wouldn't mean anything inside of a text box.
You would have to do that using a little Script entry. Alright, I'm gonna suggest something radical... Try this:
From the event commands, open a Script. Inside the little Script window, type:
"that_actors_name = $game_actors[$game_variables[61]].params(1,1)" (Or wherever the name is stored, or whatever data you want)
Then, type this:
"$game_variables[62] = that_actors_name" (Or use whichever variable number you want, if not 62)
Now, even though we usually only store numbers in $game_variables, we're storing a string. Now, when you call that data using "\v[62]" inside of a text box, the name might show up. I'm not sure if it will, you'd have to test it.
As for arrays, they're just a handy way of organizing data. For example, $game_variables is an array of 9999 variables. So when you type "$game_variables[34]", for example, you're referencing whatever's in the 34th space of the $game_variables group. Traditionally, that space is called an element or index. You can put ANYthing in there. The RPG Maker interface typically restricts you to putting a number in $game_variables, but it can really hold anything.
If that doesn't work, I thought of something else overnight:
RPG Maker also has a text box function to display a hero's name. I think it's (backslash)n[(the ID of the actor whose name you want to display)]. So, if you typed "I wonder what \n[3] is doing..." inside of a text box, and actor 3's name is Gerhard, the game would display in-game: "I wonder what Gerhard is doing..."
So, what you could do, is this:
In your database, create a hero with all blank data in, say, ID 100.
Now, in your event commands, set a little Script window and type this inside:
"$game_actors[100].params(1,1) = $game_actors[$game_variables[61]].params(1,1)"
So, you see, you're setting the name of actor 100 to the name of whoever's ID is in variable 61. Now, you can just use \n[100] to display that name. This will surely work.
You can even use conditionals to make branching paths based on what actor 100's name is. I think it should be on the second page of Conditional Branch (or whatever it's called in VX Ace) to make a decision based on what an actor's name is...
RPG Maker also has a text box function to display a hero's name. I think it's (backslash)n[(the ID of the actor whose name you want to display)]. So, if you typed "I wonder what \n[3] is doing..." inside of a text box, and actor 3's name is Gerhard, the game would display in-game: "I wonder what Gerhard is doing..."
So, what you could do, is this:
In your database, create a hero with all blank data in, say, ID 100.
Now, in your event commands, set a little Script window and type this inside:
"$game_actors[100].params(1,1) = $game_actors[$game_variables[61]].params(1,1)"
So, you see, you're setting the name of actor 100 to the name of whoever's ID is in variable 61. Now, you can just use \n[100] to display that name. This will surely work.
You can even use conditionals to make branching paths based on what actor 100's name is. I think it should be on the second page of Conditional Branch (or whatever it's called in VX Ace) to make a decision based on what an actor's name is...
Pages:
1















