How do I make a script call to check if ANY actor has a skill?

Hello.  I am making a game with more or less open classes and I want to do a script call that allows me to check if any actor has a particular skill and not a specific actor.  I've tried using these...

$gameActors.actor(1||2||3||4||5||6||7||8||9||10||11||12||13||14||15||16).isLearnedSkill(34)

$gameActors.actor(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16).isLearnedSkill(34)

$gameActors.actor(1 to 16).isLearnedSkill(34)

And I've tried spaces between the || and , respectively.

i feel like I'm close but don't understand JS enough yet to pinpoint.  It only works if the first actor learns the skill.  I'm trying to get it to check the others all at once also.

I know I can make a bunch of conditional branches to get it to work but was trying to find a less bulky and less time consuming way to do it as I will be using it a lot.

Jet made a script for VX Ace that did this but I don't have it nor can I find it to try and learn from it better, plus I know JS is different.

Any help would be appreciated.  Thanks.
try:

$gameActors._data.some(function(actor) { return actor && actor.isLearnedSkill(ID) })if you want only actors from a specific ID to check (in you example actors with id from 1 to 16 you can do:

Code:
$gameActors._data.some(function(actor) { return actor && actor.actoId() <= 16 && actor.isLearnedSkill(ID) })
Thanks for the speedy reply Vic.  I tried your code but it doesn't seem to work for some reason.

This is what I put exactly and it won't run at all.

$gameActors._data.some(function(actor) { return actor && actor.id <= 16 && actor.isLearnedSkill(34) })

I tried playing with the spacing and tried having multiple different actors learning the skill and it won't respond at all. 🙁
You said you wanted a call that checks if any actor learned the skill, and this what I provided.

This call is just a true/false statement, it won't do anything alone.

It's up to you to use this call on something relevant, like a event condition or something else.

for example, inside a plugin you can do:

Code:
if ($gameActors._data.some(function(actor) { return actor && actor.isLearnedSkill(ID) })) {  // do something} else {  // do another thing}
Thanks again for the reply.  I did.  I tried using it on an event using a conditional branch like so...

If : Script : $gameActors._data.some(function(actor) { return actor && actor.id <= 16 && actor.isLearnedSkill(34) })

  Text:  You detected a hidden staircase!

  Control Switches :  Switch #0022 = on

Else

-

End

Basically if any actor has the skill I want it to show the text and control the switch but if not then to show nothing.  Maybe I didn't ask right but there is clarification.  If not I'll just do the multiple conditional branch thing and I thank you for your time either way.
Thanks again for the reply.  I did.  I tried using it on an event using a conditional branch like so...

If : Script : $gameActors._data.some(function(actor) { return actor && actor.id <= 16 && actor.isLearnedSkill(34) })

  Text:  You detected a hidden staircase!

  Control Switches :  Switch #0022 = on

Else

-

End

Basically if any actor has the skill I want it to show the text and control the switch but if not then to show nothing.  Maybe I didn't ask right but there is clarification.  If not I'll just do the multiple conditional branch thing and I thank you for your time either way.
The error lies within your check for the ID of an actor.

Use

actor._actorId <= 16or

Code:
actor.actorId() <= 16
Thank you kiriseo!  It works great now.  JavaScript is so strange compared to Ruby that it is going to take more getting used to.  Thank you for your time and best wishes.

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-make-a-script-call-to-check-if-any-actor-has-a-skill.54598/