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,798
Reaction score
9,465
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,798
Reaction score
9,465
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
992
Reaction score
637
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
992
Reaction score
637
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 Profile Posts

Contemplating an old idea I once had about a fantasy world where elemental manipulation was possible, but combat uses required... creativity. Kinda like ATLA, but far more restricted, with a lot of physics-related realism driving what was possible.
Sniffing the enemy is important.
67lsfpj.gif
angel3.gif
Angels sprite redo came out so cute! I had to add hair so her sprite matches the new faceart :LZSexcite:
Even if you made 1% progress today in your making-game, that's 100% success!
This is Ralph from VX!
index.php

Forum statistics

Threads
121,865
Messages
1,144,763
Members
160,125
Latest member
Today
Top