Conversion of conditional branch code from VX Ace [Solved]

UIxJ99m.png


So in VX Ace, there was a function I used where it would automatically snap certain actors to the party leader position. In this example, it would scan if Actor 1 was in the party leader position - if he wasn't, these conditional branches would loop the common event that swapped characters until he was.

The middle branch is to check if he's in the battle party lineup. If he isn't part of the main five or not in the party at all, the loop will disengage.

However, in MV I can't seem to figure out the javascript version of these codes no matter how many times I look at the script call collection. Any help with this would be wonderful, since it was a very important cutscene tool.
why not using this logic
hero.id = 12 is you looking for
Code:
heroActive=0;

while( hero on group )
if hero.id == 12 heroActive=1
end while

if heroActive==1 do your stuff

heroActive can put on variable..
the problem is..
  • how to looping hero group.. use gameparty ?
    Code:
    $gameParty.allMembers()
  • how to check hero detail to have id on this the group
    Code:
    for (var num = 0; num < $gameParty.allMembers().length; num++) {
    let member= $gameParty.allMembers()[num];
                var i = member.playerId(); //???
    
     }
  • how to get variable on script.. I think
    Code:
    $gameVariables.value( number )
  • how to use variable on script.. I think
    Code:
    $gameVariables.setValue( number , default)
Code:
$gameActors.value($gameParty.prototype.battleMembers().value(0)) === $gameActors.prototype.actor(0)

$gameActors.prototype.battleMembers().contains($gameActors.prototype.actor(0))

I *THINK*, based on my general Script-Fu guidelines:

$Ace_Object => $mvObject
$Ace_Object.method_name() => $mvObject.prototype.methodName()
$Ace_Object.class_name.property => $mvObject.prototype.className().property()

>>>*LEARN PROGRAMMING, NOT CODE*<<<
@gundambison @gstv87 Thanks for trying to help me out at such an odd time of night, guys, but you're actually both wrong. :LZSwink:

The correct code wound up being:

JavaScript:
$gameParty.battleMembers()[0] === $gameActors.actor(1);

$gameParty.battleMembers().contains($gameActors.actor(1));

(I swear I don't make these "help me" threads for no reason, just based on how quickly I usually wind up finding solutions on my own. I genuinely want help when I first ask 😮‍💨)

I hope this helps anybody else who comes across this thread, just in case y'all wanted to use this code to check if party member positions is a certain person for some reason?
>>>*LEARN PROGRAMMING, NOT CODE*<<<
It looks like learning code is as important.

You are using a prototype if you are going to overwrite the function, like making a plugin, not using it in a script call.

@RCXGaming
In the future, if you're unsure of the syntax, you can press F12 while playtesting, and type whatever object you're looking for, I'm not sure if this works the same in MV, but you can expand this

1678618977043.png

1678619039227.png

1678619053678.png


Test things on console, it's one of the benefit using MV onwards.
$gameParty.battleMembers()[0] === $gameActors.actor(1); $gameParty.battleMembers().contains($gameActors.actor(1));
right.... like I said, eyeballing it.
@gundambison @gstv87 Thanks for trying to help me out at such an odd time of night, guys, but you're actually both wrong. :LZSwink:

The correct code wound up being:

JavaScript:
$gameParty.battleMembers()[0] === $gameActors.actor(1);

$gameParty.battleMembers().contains($gameActors.actor(1));

(I swear I don't make these "help me" threads for no reason, just based on how quickly I usually wind up finding solutions on my own. I genuinely want help when I first ask 😮‍💨)

I hope this helps anybody else who comes across this thread, just in case y'all wanted to use this code to check if party member positions is a certain person for some reason?
Well.. I'm thingking to give a clue. not an answer.
good things you found the answer..

for me.. checking the id is safe..
Code:
$gameParty.battleMembers()[num].id == 2
than check whole player detail..
Code:
$gameParty.battleMembers()[num]  ==  $gameActors.actor(1)
Spoiler: from google explain
The includes() method returns true if a string contains a specified string.

Otherwise it returns false.

The includes() method is case sensitive.
if
Code:
$gameActors.actor(numTarget)
not same with
Code:
$gameParty.battleMembers()[num]
it might return FALSE
the problem is.. some status/parameter on
Code:
$gameParty.battleMembers()
might already updated with other parameter and not catch same as
Code:
$gameActors.actor(numTarget)

actually my logic can use to check if 2 character on same grup.. then we can have like this
PHP:
iChar=0;

while(allHero() as hero){
   if hero.id == 1 iChar ++;
   if hero.id == 2 iChar ++;
}

if iChar == 2 then "a love bird on same group"
actually.. I tried avoid includes

Original thread: https://forums.rpgmakerweb.com/threads/conversion-of-conditional-branch-code-from-vx-ace-solved.155737/