MZ How best to set up <Command Show/Hide Switch: x>? (VisuStella Battle Core)

I'm having trouble figuring out what sort of method is required for setting up a switch for VisuStella's <Command Show Switch> (<Command Hide Switch> would work too).

I've tried Googling it and searching the forum and have found nothing.

I want to make the Attack option disappear if melee weapons aren't equipped, and I want to make the Guard option disappear if shields aren't equipped.

I'm using Galv's Auto Common Events plugin to run a common event that turns on a switch whenever the battle screen is loaded, one that runs a parallel common event that is *supposed* to check for weapon types — you may notice the screenshot has BattleManager._subject.isWtypeEquipped(x) which is probably wrong, but I've also tried user.isWtypeEquipped(x) and BattleManager.actor().isWtypeEquipped(x).

My reasoning for separating the parallel event so that it only runs on battle screen conditions is that my game is graphics intensive and I've noticed that even a single parallel event can bog it down.
I could be wrong (I often am), but my understanding is that parallel events don't run on the battle screen.
I could be wrong (I often am), but my understanding is that parallel events don't run on the battle screen.
In that case, I tried all three methods of calling the script as described in my first post without using a parallel event, and it still didn't cause the Attack or Guard commands to show.

So there must be SOME other time at which the switches are turned on or off. Is it exiting the menu screen? But then how would it account for four different actors' equipment? Isn't there just one notetag for multiple switches (ANY or ALL) but then there's no way to experiment with in-battle switches?
Have you tried using a troop event for this? With the switches being activated on turn zero with 'Span' set to Turn?
@Kes is correct, parallel and autorun common events do not run during battle.

Why go through all this finagling with switches instead of just using the code option?
Code:
<JS Command Visible>
// Does the user have any weapons equipped?
visible = user.weapons().length;
</JS Command Visible>

I'm not sure from your screenshot whether you're doing a funky implementation of shields in your game, or whether you were doing it wrong.

By default, shields are not a type of weapon, but a type of armor. Also by default, they go into equipment slot 2 (Weapon, then Shield). If that's different for your game then you'll need to modify this, but it should work for the default configuration:
Code:
<JS Command Visible>
// Does the user have anything in equip slot 2?
visible = user.equips()[1];
</JS Command Visible>
Why go through all this finagling with switches instead of just using the code option?
Code:
<JS Command Visible>
// Does the user have any weapons equipped?
visible = user.weapons().length;
</JS Command Visible>
Because I'm trying to remove the Attack option when ranged weapons are equipped. I tried <JS Command Visible> but it didn't work, and the VisuStella documentation doesn't explicitly mention that the notetag works for Attack and Guard the way it does for the <Command Show Switch> option. EDIT: I did just notice that I misunderstood the documentation on the Boolean function, I could give that a try again with a better understanding of JS.

I'm not sure from your screenshot whether you're doing a funky implementation of shields in your game, or whether you were doing it wrong.

By default, shields are not a type of weapon, but a type of armor. Also by default, they go into equipment slot 2 (Weapon, then Shield). If that's different for your game then you'll need to modify this, but it should work for the default configuration:
Code:
<JS Command Visible>
// Does the user have anything in equip slot 2?
visible = user.equips()[1];
</JS Command Visible>
You're right, I do implement shields differently, because I'm using a dual wield plugin. Arcane foci and shields count as weapons because they go in an offhand slot. But I had that set up that way so that shields could enable the Guard command before your last post, when I discovered I could check for armor type equipped to use a given skill, so I will have to make some changes eventually, since the dual wield plugin I am using affords equipping a shield in the offhand slot anyway.

Have you tried using a troop event for this? With the switches being activated on turn zero with 'Span' set to Turn?
I'll try that, thanks.
the VisuStella documentation doesn't explicitly mention that the notetag works for Attack and Guard the way it does for the <Command Show Switch> option.
You are correct, it doesn't. It would be extremely weird if it didn't, especially since it would be logical for the switch notetags to end up going through the same eval as the JS ones.

You tried the one I gave you for the weapon?

If that's not an option and you have to use switches...are you changing equipment during battle? I'm just trying to figure out why it matters that this updates during battle. If yes, the trick would be getting anything (troop event or notetag) to check specifically after you leave the in-battle equip screen.

You can just stick a passive state on actors that checks their equipment at whatever time you like. For example:
Code:
<JS Pre-Start Turn>
// I can't see all of the wTypes in your original screenshot
$gameSwitches.setValue(24, [1, 2].some(wType => user.isWtypeEquipped(wType)));
// I can't see all of the wTypes in your original screenshot
$gameSwitches.setValue(25, [66, 67].some(wType => user.isWtypeEquipped(wType)));
</JS Pre-Start Turn>

Fill out the arrays with all the applicable weapon types. Copy the notetag into as many different phases of the turn as you like, looking at the Mechanics-Related Notetags section.
You tried the one I gave you for the weapon?
No, just for the list I screenshotted. Thanks for the help, you and @Kes provided a couple of solutions here I think.

If that's not an option and you have to use switches...are you changing equipment during battle? I'm just trying to figure out why it matters that this updates during battle.
I don't know how to bring up the equip scene with ItemsEquipsCore enabled yet, but there's a VisuStella fix for BattleCore that @WingedHero devised which makes me optimistic.

EDIT: I went with @ATT_Turan's suggestion to use passive states, since I could tell using the debugging menu that <Command Hide Switch: x> works, but none of the battle-related arguments I was applying were holding. I'll have to go back and look at what I was doing wrong later today, since a partial solution is only that, but this way I'll have my cake and eat it too in case I can ever add an equip menu to the battle screen in MZ with VisuStella plugins.

Original thread: https://forums.rpgmakerweb.com/threads/how-best-to-set-up-command-show-hide-switch-x-visustella-battle-core.158632/