It works, but I would like to be a bit more specific. Is there a way to check for item types and/or categories?
You already are retrieving the item in that slot (a little problematically, but we'll look at that below), so you can simply look at those fields instead of just the ID.
I'm not sure what "categories" means, as that is not a field in RPG Maker. But the Armor Type is .atypeId, and that will correspond to the Armor Types numbers on the Types tab of your database.
I offer some notes about your code. They range from things that could cause crashes to just better or more efficient style:
- You should avoid calling the
array directly. When a getter function is provided to you, it's best practice to use that. That way, any plugins that modify how equipment works should still report the correct information to you. It also changes what kind of data object you're getting.
- If statements and loops automatically apply to the next single code statement. So there's no need to type braces unless you're doing more than one thing and you need to create a code block. It doesn't hurt anything, but it looks a little silly
- Working off of that, for a bit of efficiency - if you are ever finding yourself setting a boolean value using if/else, you can always just skip it and set it directly to the result of the conditional.
- Your conditional can cause erroneous results or crash your game. You're specifically looking at the item in the Shield slot to have an item ID of 0. This will never be true. Your item IDs start at 1. If the user has nothing equipped as a Shield and you try to look at the _itemId property, your game could crash with an error. The better way to do this is to simply ask "is
there anything in that slot?" If there's some reason you need to look at specific properties of the theoretical item, you do so after making sure it exists. In MZ, you can do that with the optional chaining operator.
So a better version of your notetag would be:
<JS Skill Enable>
</JS Skill Enable>
If you have multiple equipment types that could go in the shield slot, you can use the optional chaining operator - that says "does this property exist, and then does it have the value I'm looking at?"