A newbie question

hy i just started to use RMMZ and i am not a coder
i want to make a variable that is equal to the highest agility parameter of the party
what is the code for that to write in the script operand in the manue of the variable editing?
or is there any other way to do it?

thank you
This can be done a bit more efficiently with a script call, but it should be very easy for you to do it in event commands, so I'll show you how you would do that.

Control Variable HighestAgility -> Game Data -> Actor (first one in your party) -> Agility
Control Variable Member2 -> Game Data -> Actor (second one in your party) -> Agility
Control Variable Member3 -> Game Data -> Actor (third one in your party) -> Agility
Control Variable Member4 -> Game Data -> Actor (fourth one in your party) -> Agility
Conditional Branch Member2 > HighestAgility
- Control Variable HighestAgility = Member2
Conditional Branch Member3 > HighestAgility
- Control Variable HighestAgility = Member3
Conditional Branch Member4 > HighestAgility
- Control Variable HighestAgility = Member4

Then your HighestAgility variable is the highest in the party.

This only doesn't work well if you have one of those games where you have a bunch of characters and you don't know which actors will be in the party. Then it's more efficient to use a JavaScript function.
The game data section of the control variable command (the one that defaults to map id) is one of the most powerfull tools of the event engine.
you should try to use that instead of javascript commands whenever possible, because the event commands are protected from game-breaking influences.
if you use javascript, any mistake you make can cause a lot of problems and as such javascript should only be used when you know what you're doing and/or there is no other way to handle what you want.
If you want it to take into account all members of the party, then:
JavaScript:
Math.max(...$gameParty.allMembers().map(actor => actor.agi))

If you only want it to be based on battle members, then:
JavaScript:
Math.max(...$gameParty.battleMembers().map(actor => actor.agi))
This can be done a bit more efficiently with a script call, but it should be very easy for you to do it in event commands, so I'll show you how you would do that.

Control Variable HighestAgility -> Game Data -> Actor (first one in your party) -> Agility
Control Variable Member2 -> Game Data -> Actor (second one in your party) -> Agility
Control Variable Member3 -> Game Data -> Actor (third one in your party) -> Agility
Control Variable Member4 -> Game Data -> Actor (fourth one in your party) -> Agility
Conditional Branch Member2 > HighestAgility
- Control Variable HighestAgility = Member2
Conditional Branch Member3 > HighestAgility
- Control Variable HighestAgility = Member3
Conditional Branch Member4 > HighestAgility
- Control Variable HighestAgility = Member4

Then your HighestAgility variable is the highest in the party.

This only doesn't work well if you have one of those games where you have a bunch of characters and you don't know which actors will be in the party. Then it's more efficient to use a JavaScript function.
Ok thank you very much..... this is Genius it allows people like me who dont know java to use it.
thank you

If you want it to take into account all members of the party, then:
JavaScript:
Math.max(...$gameParty.allMembers().map(actor => actor.agi))

If you only want it to be based on battle members, then:
JavaScript:
Math.max(...$gameParty.battleMembers().map(actor => actor.agi))
ok thank you. i dont know java scripting but i can use it. cheers
who dont know java to use it.
and before you try to learn java, you should know that it would be useless here as MV/MZ use javascript, not java.

or as someone once wrote: java is to javascript as ham is to hamster: they start with the same letters but have nothing to do with each other.
and before you try to learn java, you should know that it would be useless here as MV/MZ use javascript, not java.

or as someone once wrote: java is to javascript as ham is to hamster: they start with the same letters but have nothing to do with each other.
Ok I didn't knew that. Thanks.

Original thread: https://forums.rpgmakerweb.com/threads/a-newbie-question.148688/