I cannot for some reason check if my actor has anything equipped. Nothing works

eluukkanen

Game Dev
Veteran
Joined
Feb 16, 2016
Messages
355
Reaction score
244
First Language
Finnish
Primarily Uses
N/A
I cannot for reason check if my actor has anything equipped. This should be easy, but it just won't work. Not with a script call, not with anything.

I have looked help from this topic and from Conditional Branch+
https://forums.rpgmakerweb.com/index.php?threads/check-if-actor-has-equipment-type-equipped.103836/

Conditional Branch+ worked with weapons, but not with armor

I very much wish to have it as a script call, as I have plenty of actors in the game. Using variable in line where the actor id is placed is must.

I have tried a script call like this:

$gameActors.actor($gameVariables.value(57)).equips()[2] == 14;

$gameVariables.value(57) = variable that constantly checks who is party leader
equips()[2] = should be equipment type 2 (head)
14 = should be the id of the armor

But does not work.

What am I missing...? I have no scripts on when testing (only Conditional Branch+)
 

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
3,989
Reaction score
4,916
First Language
EN, FR
Primarily Uses
RMMZ
What does it say when you call it in the console?

What is the value of $gameVaraibles.value(57)? $gameActors is organized by actor Id while all actors in the party are organized by the order in which they were added to the party (I call it the party Id). So if the variables return the party Id of the leader instead of its actor Id, then it would explain why it doesn't work (the party leader is usually the first one, so party Id would be 0, and there is no actor Id 0 it's going to return null).

Additionally, you know you can use $gameParty.leader to get the leader? Unless you have a different system than the default party system.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
35,854
Reaction score
9,494
First Language
German
Primarily Uses
RMMV
$gameVariables.value(57) = variable that constantly checks who is party leader
how did you do this?
by default all variables contain the value when they were set, they do NOT constantly update.

so one possible cause for the error is that the variable might point to the wrong actor, please show us how you set it.
 

eluukkanen

Game Dev
Veteran
Joined
Feb 16, 2016
Messages
355
Reaction score
244
First Language
Finnish
Primarily Uses
N/A
how did you do this?
by default all variables contain the value when they were set, they do NOT constantly update.

so one possible cause for the error is that the variable might point to the wrong actor, please show us how you set it.

You can do it with $gameParty.leader but $gameVaraibles.value(57) is not always the party leader. Script chooses depending on the situation what party member is doing what and etc. This is not that is not working. All my other setups have no problem making $gameActors.actor($gameVariables.value(57)) into $gameActors.actor(1) as example when needed.

The problem lies somehow on how I put the conditional branch on the script. I could use conditional branch of event, but as I am using a variable, having it scripted would help and save a ton of time.

What script conditional works for you when checking equipment?
 

eluukkanen

Game Dev
Veteran
Joined
Feb 16, 2016
Messages
355
Reaction score
244
First Language
Finnish
Primarily Uses
N/A
Here is a picture on the event + on the event. Am I missing something... :LZSooo:

testing armor.jpg
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
35,854
Reaction score
9,494
First Language
German
Primarily Uses
RMMV
Sometimes it's the small errors - I didn't spot it at first because I rarely use javascript, but if I remember correctly you need to use === instead of == for comparisons in javascript.
 

ramza

Lunatic Coder
Veteran
Joined
Jan 28, 2013
Messages
996
Reaction score
643
First Language
English
Primarily Uses
RMMV
I cannot for reason check if my actor has anything equipped. This should be easy, but it just won't work. Not with a script call, not with anything.

I have looked help from this topic and from Conditional Branch+
https://forums.rpgmakerweb.com/index.php?threads/check-if-actor-has-equipment-type-equipped.103836/

Conditional Branch+ worked with weapons, but not with armor

I very much wish to have it as a script call, as I have plenty of actors in the game. Using variable in line where the actor id is placed is must.

I have tried a script call like this:

$gameActors.actor($gameVariables.value(57)).equips()[2] == 14;

$gameVariables.value(57) = variable that constantly checks who is party leader
equips()[2] = should be equipment type 2 (head)
14 = should be the id of the armor

But does not work.

What am I missing...? I have no scripts on when testing (only Conditional Branch+)
Sorry for responding so late after your initial post, I hope that you've already found the issue here, but I have also found it and will explain why this doesn't work for you.

First, whatever you're using to set that variable to the actorId of the party leader is probably unnecessary. $gameParty.leader() is the leader of the party. $gameParty.members()[0] is also the leader of the party. To check the equipment of the leader, $gameParty.leader().equips()[x] returns the item in slot x of the leader. This is an important distinction to make, because it is returning an object, not the Armor Id of that object, and this is the reason your check is failing. The correct check is below:
$gameParty.leader().equips()[2].id === 14
 

eluukkanen

Game Dev
Veteran
Joined
Feb 16, 2016
Messages
355
Reaction score
244
First Language
Finnish
Primarily Uses
N/A
Much appreciated! It partly works. Only problem with it is that if the party leader has nothing equipped, there is a crash with the conditional event. It only functions if there is that certain equipment equipped, which kinda breaks any usage it has unfortunately ;_;

It says: Cannot Read property "id" of null

This was tested in a regular project without any other script involved.
 

eluukkanen

Game Dev
Veteran
Joined
Feb 16, 2016
Messages
355
Reaction score
244
First Language
Finnish
Primarily Uses
N/A
Sorry for responding so late after your initial post, I hope that you've already found the issue here, but I have also found it and will explain why this doesn't work for you.

First, whatever you're using to set that variable to the actorId of the party leader is probably unnecessary. $gameParty.leader() is the leader of the party. $gameParty.members()[0] is also the leader of the party. To check the equipment of the leader, $gameParty.leader().equips()[x] returns the item in slot x of the leader. This is an important distinction to make, because it is returning an object, not the Armor Id of that object, and this is the reason your check is failing. The correct check is below:
$gameParty.leader().equips()[2].id === 14

This is what it shows with
$gameParty.leader().equips()[2].id === 14
If there is nothing equipped

test it.jpg
 

ramza

Lunatic Coder
Veteran
Joined
Jan 28, 2013
Messages
996
Reaction score
643
First Language
English
Primarily Uses
RMMV
This is what it shows with
$gameParty.leader().equips()[2].id === 14
If there is nothing equipped

View attachment 134013
In your conditional branch, do an && check to make sure the item exists before the original check.

Code:
$gameParty.leader().equips()[2] && $gameParty.leader().equips()[2].id === 14
This will check first if the item exists (or isn't nothing), and then check the items Id if it does exist. It will return false if it doesn't exist, so it won't crash.
 

Attachments

  • equip check.PNG
    equip check.PNG
    35.1 KB · Views: 3

eluukkanen

Game Dev
Veteran
Joined
Feb 16, 2016
Messages
355
Reaction score
244
First Language
Finnish
Primarily Uses
N/A
Ah, got it! Thank you Ramza once again!
 

Latest Threads

Latest Posts

Latest Profile Posts

Unfortunately, while trying to run an app I needed (curse you, Adobe!), my laptop blacked out, so my data got wiped when I got it repaired. Stuff like facesets are saved in my drive, but my sprites now only exist as screenshots I've taken in the past :kaocry:To be fair, I'm a little relieved, since I've been feeling unsatisfied with the visual style of the character sprites, and I guess I can now revamp them?

after lot's of edits to Mike's attacks (to make it seamless with movement, no EX versions, cost 1-ups), I finally got combo skills to work. had to do a lot moving tho to get the combo list to appear where it is lol. that actually took longer than setting up the moves.
What's kind of amazing is I've been in a developmental rut for the LONGEST time but putting a music mix on of video game soundtracks and specifically hearing the VX Ace music come up and it's nostalgia of me being excited to make my first game has REALLY got me going again!
Finally finished my tiefling!
F222514F-9F32-4B97-88C3-664E8A2134C3.gif

Forum statistics

Threads
122,029
Messages
1,145,963
Members
160,291
Latest member
arnvrl
Top