Setting a variable to match a party member's parameter?

Okay, so I'm setting up a little gambling minigame. Basically, it randomizes a variable and, depending on how high that variable is, the player gets prizes of varying values. I want to make it so that after the variable is randomized, the combined luck of all the party members is added in (basically, "lucky people are better at gambling").
How can I access the parameters of party members without specifying actors? I have a set of variables that set to the Actor ID's of the different party members. Is there any way to do this without using conditional branches for every available playable character?
Here's a cap of the event, without the prizes or anything included.
Whew, took some experimentation but I finally found it. This is the script call:

$game_party.members[X].luk

Where X is the party position, 0 for leader, 1 for next, etc. You could set or add this to a variable to get the value of X party member's Luck stat. You can set up a loop to run it for each member depending on how many members you have. 😤


Alternatively, you can use this format if you already have the actor IDs:

$game_actors[Y].luk

Where Y is the ID of the actor. If it's in a variable, you can do something like:

$game_actors[$game_variables[Z]].luk

Where Z is the number of the variable it's stored in. 👋
Whew, took some experimentation but I finally found it. This is the script call:

$game_party.members[X].luk

Where X is the party position, 0 for leader, 1 for next, etc. You could set or add this to a variable to get the value of X party member's Luck stat. You can set up a loop to run it for each member depending on how many members you have. 😤


Alternatively, you can use this format if you already have the actor IDs:

$game_actors[Y].luk

Where Y is the ID of the actor. If it's in a variable, you can do something like:

$game_actors[$game_variables[Z]].luk

Where Z is the number of the variable it's stored in. 👋
Works like a charm! Thank you so much! 😍
Code:
$game_party.members.inject(0) { |total, member| total + member.luk }

That'll get the combined total luk of all party members without the need for a loop or a game variable.
Code:
$game_party.members.inject(0) { |total, member| total + member.luk }

That'll get the combined total luk of all party members without the need for a loop or a game variable.

Thanks, man!

Is it possible to collect only the ".luk" of party members who are alive?
Necro-post notice: Ayoni
It is also hijacking a thread by asking a question which is different from that of the OP.

At this point I usually advise people to start their own thread - but you already have a thread on this topic. Please do not multi post your query. One query, one thread.
Moderator note: Closing this

Original thread: https://forums.rpgmakerweb.com/threads/setting-a-variable-to-match-a-party-members-parameter.76774/