Hey guys! So as the title says, I need some help trying to get the position of actors in the battle into a variable. I have actually figured out a way of doing so by doing the following script call:
$gameVariables.setValue(30, $gameParty.members()[3].actorId());
However the problem I run into is what if there is no actor in that position? In this case its the 4th position (with 0 being position 1). When I run the script call I get an error saying that actorId is undefined because there is no actor in that position. Is there a way for me to still perform a check if there is an actor in that position and if not then continue with the rest of the script call?
This is essentially what I'm trying to do:
Actor ID #1 uses a Skill which performs the following:
$gameActors.actor($gameVariables.value(29)).addState(72);
Then a common event plays which does the last bit of the skill:
$gameVariables.setValue(30, $gameParty.members()[0].actorId());
if ($gameVariables.value(30) === $gameVariables.value(29)) {
$gameParty.members()[0].startAnimation(140);
}
$gameVariables.setValue(31, $gameParty.members()[1].actorId());
if ($gameVariables.value(31) === $gameVariables.value(29)) {
$gameParty.members()[1].startAnimation(140);
}
$gameVariables.setValue(32, $gameParty.members()[2].actorId());
if ($gameVariables.value(32) === $gameVariables.value(29)) {
$gameParty.members()[2].startAnimation(140);
}
$gameVariables.setValue(33, $gameParty.members()[3].actorId());
if ($gameVariables.value(33) === $gameVariables.value(29)) {
$gameParty.members()[3].startAnimation(140);
}
tldr; So basically I have a skill call a common event where the character that used a skill that has its own actor ID as variable #29 and then adds a state to that character. The second part of the skill then plays an animation on the character. But if there is no actor in that troop position I get an error. I'm also not a super advanced javascript user so please pardon me for my noobie looking script ^_^. Any help would be greatly appreciated!
$gameVariables.setValue(30, $gameParty.members()[3].actorId());
However the problem I run into is what if there is no actor in that position? In this case its the 4th position (with 0 being position 1). When I run the script call I get an error saying that actorId is undefined because there is no actor in that position. Is there a way for me to still perform a check if there is an actor in that position and if not then continue with the rest of the script call?
This is essentially what I'm trying to do:
Actor ID #1 uses a Skill which performs the following:
$gameActors.actor($gameVariables.value(29)).addState(72);
Then a common event plays which does the last bit of the skill:
$gameVariables.setValue(30, $gameParty.members()[0].actorId());
if ($gameVariables.value(30) === $gameVariables.value(29)) {
$gameParty.members()[0].startAnimation(140);
}
$gameVariables.setValue(31, $gameParty.members()[1].actorId());
if ($gameVariables.value(31) === $gameVariables.value(29)) {
$gameParty.members()[1].startAnimation(140);
}
$gameVariables.setValue(32, $gameParty.members()[2].actorId());
if ($gameVariables.value(32) === $gameVariables.value(29)) {
$gameParty.members()[2].startAnimation(140);
}
$gameVariables.setValue(33, $gameParty.members()[3].actorId());
if ($gameVariables.value(33) === $gameVariables.value(29)) {
$gameParty.members()[3].startAnimation(140);
}
tldr; So basically I have a skill call a common event where the character that used a skill that has its own actor ID as variable #29 and then adds a state to that character. The second part of the skill then plays an animation on the character. But if there is no actor in that troop position I get an error. I'm also not a super advanced javascript user so please pardon me for my noobie looking script ^_^. Any help would be greatly appreciated!