Script: check if the actor is equipped with a weapon

Hello

I need help, I am creating a verification script, where I verify if the actor or group is equipping a weapon, I leave below the script I have.

Code:
$gameActors(1).equips(0).nil?

Greetings and thanks
use f8 in game (the console) and write :
$gameActors
(+ use enter)
than you can find all related data which is in your project
Screenshot_1.png
You could try this:
JavaScript:
$gameActors.actor(1).weapons().length
It will be truthy if actor ID 1 has at least 1 weapon, else falsy.
It can be used in Conditional Branch > Script, or an if statement in a script call or plugin.
You could try this:
JavaScript:
$gameActors.actor(1).weapons().length
It will be truthy if actor ID 1 has at least 1 weapon, else falsy.
It can be used in Conditional Branch > Script, or an if statement in a script call or plugin.

Yes it worked for me, thank you very much!

this code also works
Code:
$gameParty.leader().weapons().length
Yes it worked for me, thank you very much!

this code also works
Code:
$gameParty.leader().weapons().length
Note that this checks the equips of the party leader, who might not necessarily be actor ID 1. Depends what you're going for, how the player is allowed to rearrange the party, etc. 🙂

Good to hear you got it working, though! Happy RPG Making~ 😂

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/script-check-if-the-actor-is-equipped-with-a-weapon.130002/