Check if Actor has Accessory/Head/Body Armor Equipped

Joined
Aug 6, 2016
Messages
95
Reaction score
5
First Language
English
Primarily Uses
Hello guys!


Quick question.... How do you put in the conditional branch script call if you want to check if Actor 'A' has a Body armor equipped? Same goes for Accessory and Headgear.


To put it simply, I'd like to check if the armor slot (based on equip type) is empty or not.


Something similar to this: $game_actors[12].weapons.empty? 


but that was for weapon, how about headgear/accessory/etc. ?


I don't think $game_actors[12].armors.empty?  will be able to tell specifically based on it's equip type..


Please help, guys.. Thanks a lot.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Code:
!$game_actors[12].equips[slot_id].object.nil?


will be true if the slot is filled, and false if there is nothing there.  Replace slot_id with 0:weapon, 1:shield, 2:head, 3:body, 4:accessory.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
I have been trying for a while to do the exact same thing, but I don't see how to use that script call.  If I put it into a conditional branch, so that if true the NPC says one thing, if false says another, I get an error message because the conditional cannot detect whether it is true or not.  Presumably there's another step required?
 
Joined
Aug 6, 2016
Messages
95
Reaction score
5
First Language
English
Primarily Uses
Code:
!$game_actors[12].equips[slot_id].object.nil?


will be true if the slot is filled, and false if there is nothing there.  Replace slot_id with 0:weapon, 1:shield, 2:head, 3:body, 4:accessory.
I tried using


!$game_party.members[0].equips[4].object.nil?


to check the 1st member's accessory, but it comes up with an error message says: undefined method 'object' for nil:nilclass


or something like that... I tried new game but it doesn't work... Did I do something wrong?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
I wonder if it compresses the array so there are no 'empty' elements ...


Can you please try this in a script call, and play with the console on, and let me know what it says?  Might need to grab a screenshot of the console window, as you can't copy/paste from it:

Code:
p $game_party.members[0].equips.to_s
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
That's the same error message I got, and I tried it in new game.  I see you changed the script call to party.members, but that's not the cause as I got it with game_actors as per the original.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Just did some testing.  Leave out .object

Code:
!$game_party.members[0].equips[4].nil?

or 

!$game_actors[id].equips[4].nil?


will be true if the actor/party member has an accessory equipped.
 
Joined
Aug 6, 2016
Messages
95
Reaction score
5
First Language
English
Primarily Uses
I wonder if it compresses the array so there are no 'empty' elements ...


Can you please try this in a script call, and play with the console on, and let me know what it says?  Might need to grab a screenshot of the console window, as you can't copy/paste from it:

Code:
p $game_party.members[0].equips.to_s
This is what it says:console.png


FYI my first party member only got a weapon equipped and the rest of the slots are empty
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
I figured out the problem and the solution is above your post.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
Works fine for me.


Thanks.
 
Joined
Aug 6, 2016
Messages
95
Reaction score
5
First Language
English
Primarily Uses
Just did some testing.  Leave out .object

Code:
!$game_party.members[0].equips[4].nil?

or 

!$game_actors[id].equips[4].nil?


will be true if the actor/party member has an accessory equipped.
Alright thanks a lot! It worked perfectly!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,045
Members
137,569
Latest member
Shtelsky
Top