akaneko

Villager
Member
Joined
Jun 28, 2021
Messages
14
Reaction score
4
First Language
vietnamese
Primarily Uses
RMMV
Is there any script command to get the actor id at the last place in the party?
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
2,828
Reaction score
2,164
First Language
EN
Primarily Uses
RMMZ
Try this (e.g. in Control Variables -> Script):
JavaScript:
var m = $gameParty.members(); m[m.length - 1].actorId()
This assumes there is at least one actor in the party.

If you only want to check the active/battle party (ignoring reserve members) then use battleMembers instead, e.g.
JavaScript:
var m = $gameParty.battleMembers(); m[m.length - 1].actorId()
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
33,879
Reaction score
8,586
First Language
German
Primarily Uses
RMMV
it can also be done without scripts by event commands alone, but then it is a bit more complex.

you can use control variable to get the actor ID on any party position, and when that returns zero you know there is no longer a party member and you'll have to use the previous index for the last member
 

Piyan Glupak

Veteran
Veteran
Joined
Nov 14, 2016
Messages
99
Reaction score
47
First Language
English
Must admit that I would be tempted to get the party size by using the event command "control variable" > "Game Data" > "Others" > "Party Members". For example, let's say that you set variable number 10 to store "Party Members".

The index of party members starts at 0, so, for example, for a party of 4, the index of the last party member would be 3. You need subtract 1 from the variable that you put the party size into, so another "control variable" command for variable number 10, this time just subtract 1.

Next, use one line of script in a "control variable" to return the actor id that you want:

$gameParty.members()[$gameVariables.value(10)].actorId();

Total of 3 "control variable" editor commands, with just a fragment of script in the third.

Edit: This assumes that you are just doing an event. I prefer the above because I would find it easy to understand and revise in a few months time. If you are writing a plugin then of course caethyril's script would be what you want.
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
2,169
Reaction score
1,160
First Language
English
Primarily Uses
RMMV
Total of 3 "control variable" editor commands, with just a fragment of script in the third.
It seems to me that if you're going to have any script boxes filled in at all, there's no reason to use 3 event commands instead of just one. So you'd just Control Variable -> Script:
Code:
$gameParty.battleMembers()[$gameParty.battleMembers().length-1].actorId()

Note: I'm presuming that the OP saying "the last position in the party" means the last follower. If you meant the last person of all actors you have recruited (so, I guess, the most recent?), you'd replace both instances of battleMembers with just members.
 

Latest Threads

Latest Profile Posts

I'm having toooo much fun designing the new MP (Mental Psyche) system. I've only worked it out for enemies so far, but it's fun to stun them, then go after their MP and delete them instead to farm for better item drops.
anyone know of a place I can promote my game? sorta like game awards but for indie devs, like a place where I can drop a trailer and like stir up some hype
Doing RPG Maker News for 17th October 2021

That moment when you came up with a very good game title, but when you searched it, it has already been used... T.T
Crazy week. My anxiety decides to go nutz. Worse thing about it is that it causes me to lose focus on my work. I was able to leave early one day and take a nap. Seemed to help. How is everyone? Boosters coming soon here. Get my life back on track again.

Forum statistics

Threads
115,874
Messages
1,093,657
Members
151,119
Latest member
raidans
Top