Party member attack to variable issue

Poppie360

chocobo wrangler
Veteran
Joined
Feb 28, 2018
Messages
180
Reaction score
54
First Language
English
Primarily Uses
RMMV
Hi, im having a small issue with the map based battle system i'm making. i cannot set a variable of the ATK of a party member. here's a screenshot of the section of the event and the respective error atributed to it:

any help is appreciated, as i haven't been able to find a solution to this yet.
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
How many members are in the party when that error happens? My guess is that you have less than 3 party members.

To find out, when the error happens, open the console by pressing F8.
Type this and press enter:
Code:
$gameParty.members();
Then you can check how many, and can expand the results to see more details.
 

Poppie360

chocobo wrangler
Veteran
Joined
Feb 28, 2018
Messages
180
Reaction score
54
First Language
English
Primarily Uses
RMMV
ah, that'd make sense, let me try something for a second

EDIT: yes, that was the issue.

do you know how to check the size of the party then? some things are dependent on how many you have in your party, i'll have to create a conditional branch
 

Astfgl66

Veteran
Veteran
Joined
Jan 5, 2016
Messages
722
Reaction score
578
First Language
French
Primarily Uses
You'll probably want to do that with a loop anyway, its both cleaner and more efficient and will save you party size checks.
Something like that should work
Code:
var members =$gameParty.members()
for (var i = 0; i < members.length; i++) { //loop through all members
 $gameVariables.setValue(69 + i, members[i].atk) //set variable 69 to party member 1 attack, 70 pm 2, 71 pm 3
}
You can add lines to that loop to store defense or anything else really, just change the default variable number.

To check party size just type:
$gameParty.members().length
 

Poppie360

chocobo wrangler
Veteran
Joined
Feb 28, 2018
Messages
180
Reaction score
54
First Language
English
Primarily Uses
RMMV
You'll probably want to do that with a loop anyway, its both cleaner and more efficient and will save you party size checks.
Something like that should work
Code:
var members =$gameParty.members()
for (var i = 0; i < members.length; i++) { //loop through all members
 $gameVariables.setValue(69 + i, members[i].atk) //set variable 69 to party member 1 attack, 70 pm 2, 71 pm 3
}
You can add lines to that loop to store defense or anything else really, just change the default variable number.

To check party size just type:
$gameParty.members().length
thanks, although i only need to check it once at the beginning of the event. (due to it being just an event that runs once to set up variables needed for calculations) $gameParty.members() was the correct script call needed. (not sure 100% how to mention someone) but thanks @Aloe Guvner for helping out with this as well. the thread can be closed thanks to the issue being resolved.
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
thanks, although i only need to check it once at the beginning of the event.
Actually, @Astfgl66 suggestion is exactly this. You could try his/her suggestion in a Script Call Event Command, because you then you don't need to worry about how many members are in the party. It will figure that out for you.

For example, in your screenshot, you might have 1 or 2 or 3 members in the party.

What his/her code is doing:
  • Set Variable #69 to the first member attack
  • Set Variable #70 to the second member attack (if there is a second member!)
  • Set Variable #71 to the third member attack (if there is a third member!)

This is exactly the same as the suggestion, just written more concisely:
Code:
$gameParty.members.forEach(function(actor, i){$gameVariables.setValue(69 + i, actor.atk);});
$gameParty.members.forEach(function(actor, i){$gameVariables.setValue(73 + i, actor.def);});
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,049
Members
137,569
Latest member
Shtelsky
Top