How do I find out if a specific actor has a certain Weapon Type equipped?

I want to have certain things happen if an actor has a certain Weapon Type equipped... Like only dagger related objects are given at a store if you have a Dagger Type weapon equipped. I need it in a script call since I'd like to use it with scripts that use that as well.
The actor class has an isWtypeEquipped function that is for exactly this.

If, say, you wanted to check whether any party member had a dagger equipped, you could use the following in a conditional branch:

Code:
$gameParty.members().some(function(member) { return member.isWtypeEquipped(1) } );

This will cause the branch to run if any member of your party has a dagger-type weapon equipped.
@Trihan beat me to the punch, and his whole party method is way more elegant than the one I cooked up. But if you wanted to check a particular actor, by either actorId or party position I have those options below. (Beware of capitalization errors; I spent a good 15 minutes tracking one down.) Replace the bold items with the relevant number.

By actorId:

$gameActors.actor(actorId).isWtypeEquipped(wtypeId);

By party position (note that the party leader is position 0):
$gameParty.members()[position].isWtypeEquipped(wtypeId);
Good call on providing alternatives @Llareian ; I mainly went with the whole party method because presumably in the example usage of only having daggers in a shop if someone has a dagger equipped you wouldn't be too fussed about *who* has the dagger equipped.
@Trihan Most of the time that's totally true, especially for the case given here, but I like to provide alternatives in case someone in the future might need them. 🙂 It's frustrating finding a thread that ALMOST answers your question -- but not quite.
Thanks to both of you! @Llareian Thanks for providing the alternatives... They were perfect.

I was actually using Yanfly Common Event Menu and needed a way to hide one of the options when a certain actor has a certain Weap[on Type equipped... It works great now, thanks!

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-find-out-if-a-specific-actor-has-a-certain-weapon-type-equipped.85932/