Check if Player Coord. equal Follower Coord. via Conditional Branch Script Call

I try to create a 'Snake' minigame and need to check if the Player Coordinates are equal to the Coordinates of my followers (to check if i 'bite' myself).

I would like to achieve this with a Conditional Branch script or something else, to execute an action whenever a conditional branch for X and Y coordinates match. I know that i could check the follower and Player coordinates after every step with the Map X of Player and $gamePlayer._followers.follower(0).x, store everything in variables and compare them, but that would be too much work, especially if i had 10+ 'Body parts' (followers). I use HIME_GuestFollowers Plugin to be able to have more than 4 followers.

If you have an even easier solution, I would love to hear it 🙂

I've moved this thread to RPG Maker MV. Thank you.

Hi!
Assuming that Hime adds the followers with the default code, you can use that in a script call:

JavaScript:
const followers = $gamePlayer._followers._data;
let l = followers.length;
if(!l > 0) return;
while(l--){
    if($gamePlayer._x === followers[l]._x && $gamePlayer._y === followers[l]._y){
        //do something.
        break; // you can use this word optionally if you want to interrupt the check after find one match.
    }
}

If the player has one or more followers, it will check the player's position with all the followers he has.
If one matches with the same position, you do your code.
Hi!
Assuming that Hime adds the followers with the default code, you can use that in a script call:

JavaScript:
const followers = $gamePlayer._followers._data;
let l = followers.length;
if(!l > 0) return;
while(l--){
    if($gamePlayer._x === followers[l]._x && $gamePlayer._y === followers[l]._y){
        //do something.
        break; // you can use this word optionally if you want to interrupt the check after find one match.
    }
}

If the player has one or more followers, it will check the player's position with all the followers he has.
If one matches with the same position, you do your code.


Thank you for your reply ^^ but your Code sadly didn't work (SyntaxError Illegal return statement), maybe i'm just too dumb to use it, i'm completely new to programming, but i got something to work with the following:

JavaScript:
if ($gamePlayer.x === $gamePlayer.followers().follower(index).x && $gamePlayer.y === $gamePlayer.followers().follower(index).y) {//do something}

But it only works with the first 4 Guest Followers from HIME_GuestFollowers Plugin...
So is there any way that this can interact with the other Guest-Followers? Maybe a different Plugin that i wasn't able to find?
Maybe try to replace that part
if(!l >0) return;
With this one.
if(!l >0){return false};
If it didnt work, I will try tomorrow again.
Maybe try to replace that part
if(!l >0) return;
With this one.
if(!l >0){return false};
If it didnt work, I will try tomorrow again.


Got the exact same Problem :/ the Code for testing looks like this (set Player transparent only to see if it works),
maybe there are some mistakes that i made because i dont now what i'm doing xD:

JavaScript:
const followers = $gamePlayer._followers._data;
let l = followers.length;
if(!l >0){return false};
while(l--){
    if($gamePlayer._x === followers[l]._x && $gamePlayer._y === followers[l]._y){
        $gamePlayer.setTransparent(true)
    }
}

Original thread: https://forums.rpgmakerweb.com/threads/check-if-player-coord-equal-follower-coord-via-conditional-branch-script-call.122325/