How do I make a skill appear only if the user is Class OR Subclass?

Example:

Archer Class can use "Archery" skill

I want people that are also Subclass Archer to use "Archery"

this is the code that works for the Class, but I just cannot figure out how to add the "or subclass" or else if subclass

<Custom Show Eval> if (user.currentClass().id === 21) { visible = true; } else { visible = false; } </Custom Show Eval>

these 2 are ways I was trying to add and it doesn't work with even the class:

<Custom Show Eval> if (user.currentClass().id === 21) || (user.subclass().id === 21) { visible = true; } else { visible = false; } </Custom Show Eval>

<Custom Show Eval> if (user.currentClass().id === 21) { visible = true; } else if (user.subclass().id === 21) { visible = true; } else { visible = false; } </Custom Show Eval>


Thanks for your time I appreciate it!🙂
It seems like you're closing the evaluation of the if statement after the first condition and the second one becomes a fragment

What happens if you change the second line here:

<Custom Show Eval>
if (user.currentClass().id === 21) || (user.subclass().id === 21) {
visible = true;
} else {
visible = false;
}
</Custom Show Eval>

To this
if (user.currentClass().id === 21 || user.subclass().id === 21) {
You should always make sure to specify (and link to) the plugins you're asking about. I'm presuming from your post and notetags that it's the Yanfly Engine class plugins, but that's technically a guess.

You can also clean up and shorten your code a lot, like this:
this is the code that works for the Class
<Custom Show Eval> visible = user.currentClass().id ===21; </Custom Show Eval>
There was nothing broken in your first example, but the shorter it is, the more readable it is (and the less chance for error).

It seems like you're closing the evaluation of the if statement after the first condition
That's exactly right. Again, you can make the code shorter - any time you find yourself using if/else just to set a boolean value, you can always skip them entirely.
Code:
visible = user.currentClass().id==21 || user.subclass().id==21;
It seems like you're closing the evaluation of the if statement after the first condition and the second one becomes a fragment

What happens if you change the second line here:

<Custom Show Eval>
if (user.currentClass().id === 21) || (user.subclass().id === 21) {
visible = true;
} else {
visible = false;
}
</Custom Show Eval>

To this
if (user.currentClass().id === 21 || user.subclass().id === 21) {
Wow, so if I include a or statement than I have to not close off the first statement, and include the second statement inside, noted!

@ATT_Turan Thank you as always for helping me shorten my extremely long blocks of code 😅
If I want to include let's say, 2 or even 3 classes and subclasses can I include those in that line of code somehow?

You guys are the best, really!
Wow, so if I include a or statement than I have to not close off the first statement, and include the second statement inside, noted!
Yes, the syntax for if statements is if (condition)
Using AND or OR is multiple comparisons but all one condition.

If I want to include let's say, 2 or even 3 classes and subclasses can I include those in that line of code somehow?
I don't understand how that's different from the examples that were already provided.
Yes, the syntax for if statements is if (condition)
Using AND or OR is multiple comparisons but all one condition.


I don't understand how that's different from the examples that were already provided.
I figured it out, thank you so much!

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-make-a-skill-appear-only-if-the-user-is-class-or-subclass.156695/