Yanfly Selection Control - selecting target rows

Hi!

I am having an issue creating a custom select condition with Yanfly's Selection Control. I think I am on the right track, as the code works to an extent, but I can't get it work as I would like.

I have 5 party members; one each in a separate row (row 1 to 5). For context the rows are arranged horizontally rather than vertically (think of rows like in Plants vs Zombies). I also have 5 enemies, one in each row also (set using default row notetag). They are both lined up facing each other with player 1 facing enemy 1 and so forth.

I have a skill that I would like to restrict targets to enemies/players in the same row OR adjoining rows. i.e player character in row 3 can use the skill on an enemy in row 2, 3 and 4, but not 1 or 5.

I have come up with code below;

<Custom Select Condition>
if (target.row() >= user.row()) {
condition = true;
} else {
condition = false;
}
</Custom Select Condition>

The problems I have are as follows;
1. I cannot have the character/enemy attack their corresponding character/enemy on the same row by using '==' or '==='. The skill is greyed out i.e not meeting the condition.
2. Using the above I can have the character/enemy attack their corresponding character/enemy on the same row, but also those in rows 'higher' that those. i.e player character in row 3 can use the skill on an enemy in row 3, 4 or 5.

I have used 'battler.row()' in lieu of 'target.row()' or 'user.row()' which brings up an error. My first attempt at was as follows and did not work probably for the same reasons as problem 1 listed above;

<Custom Select Condition>
if (target.row() === user.row()) {
condition = true;
} else {
if ((target.row() === user.row()) + 1) {
condition = true;
} else {
if ((target.row() === user.row()) - 1) {
} else {
condition = false;
}
</Custom Select Condition>

Any assistance would be greatly appreciated.
...
<Custom Select Condition>
if (target.row() === user.row()) {
condition = true;
} else {
if ((target.row() === user.row()) + 1) {
condition = true;
} else {
if ((target.row() === user.row()) - 1) {
} else {
condition = false;
}
</Custom Select Condition>
I see a few little mistakes here, but not to worry! See if this works any better:
Code:
<Custom Select Condition>
if (target.row() === user.row()) {
  condition = true;
} else if (target.row() === user.row() + 1) {
  condition = true;
} else if (target.row() === user.row() - 1) {
  condition = true;
} else {
  condition = false;
}
</Custom Select Condition>
(The indents aren't necessary, but they help make the code a little more readable.)
Hi Caethyril

Thanks for your help. Unfortunately I am still having the same issue. I think it has more to do with the way I am trying to use the custom selection condition. I think the issue is that I can't select a target without the selection condition doing a check to see if there is a valid target to begin with. When I use >= or <=, it opens the scope up to more valid targets. I will play around with it tonight.

Thanks again!
Update!

I still don't understand why the code below does not allow me to select the target if it is in the same row as the user.

<Custom Select Condition>
if (target.row() === user.row()) {
condition = true;
} else {
condition = false;
}
</Custom Select Condition>

Flipping it around a bit, such as this example doesn't work either.

<Custom Select Condition>
if (user.row() != target.row()) {
condition = false;
}
</Custom Select Condition>

The reason I am confused is because the following code works as you'd expect. If the target is in the same row as the user, the condition is false and you can't select them (but you can select all the other targets).

<Custom Select Condition>
if (target.row() === user.row()) {
condition = false;
}
</Custom Select Condition>

As does this code, if the target is in row 1, it is the only valid target.

<Custom Select Condition>
if (target.row() === 1) {
condition = true;
} else {
condition = false;
}
</Custom Select Condition>

Are enemy row's treated differently to character row's? Such as there is a enemy row 1 and a character row 1? Any help is appreciated. I feel like I may be misunderstanding something fundamental here, because I can get plenty of predictable results, just not the one i'm after!
I just tested in a v1.5.2 project with only the required plugins (Battle Engine Core, Target Core, Selection Control, Row Formation) and all the tags you cited, as well as my suggestion, seem to work as expected for me? The only plugin setting I changed was row count (increased from 3 to 5).

Selection Control requires both Target Core and Battle Engine Core, so make sure they're present and enabled in the Plugin Manager. Also make sure your Yanfly plugins are in the correct order as listed here. Could check whether your plugins are up-to-date as well. Hopefully one of those things will fix it for you. =)
Update!

I figured it out. You were 100% correct Caethyril. The code does work. I did the same thing and made a sample project. Which then led me on a witch hunt through my other plugins. I have one called 'no attack' by Tamfey, which removes the default 'attack' command. I got rid of this and it worked as expected. Not wanting to give up on the features of 'no attack', I tried Himeworks actor battle commands. Unfortunately it produced the exact same issue. It seems that I have to decide between 'no attack' and selection control. I have a feeling it would be conflicting in other ways too, so I'll lose 'no attack'.

Thanks for your help! got there in the end.
Plugins! *shakes fist* Glad I could help, though! 🙏

Just a shot in the dark, but does putting your 'no attack' plugin between Yanfly's Battle Engine Core and Target Core in the load order help at all?
I shifted the load order around in the hope that there would be a way for them to play along, but it looks like there is a pretty strong conflict. It may have been affecting other plugins without my knowledge, so maybe it was for the best. I can find a way to work around the attack/guard commands I think. Thanks again!

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-selection-control-selecting-target-rows.96076/