RMMV Having property errors, need a different scripts I think

petpous

Villager
Member
Joined
Apr 25, 2021
Messages
23
Reaction score
1
First Language
English
Primarily Uses
RMMV
So I need to check which weapon and armour are equipped and previously I was given this script:

$gameActors.actor(1).equips(1)[0].id === 42
But it said it can't read property "id" of null

But TBH it's not really the script I want anymore
I was to use the variable command and set the variable to the id of the armour equipped
However, because the game has hats, tops, leggings and boots how can I check for a specific hat equipped because 4 armour would be equipped at once right? so it can't set the variable to 4 different types of armour

Anyone know a script to change a variable to the ID of a specific type of armour equipped by a specific actor?
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
1,159
Reaction score
636
First Language
English
Primarily Uses
RMMV
$gameActors.actor(1).equips(1)[0].id === 42
I don't know where you got this script, because it has several things wrong. The equips() function simply returns the array of the actor's equipment, passing it a 1 doesn't do anything. Additionally, any time you look at a part of an array (the number in brackets), you want to check that it exists first. If you run this code and a character doesn't have anything equipped in slot 0, it will crash with the error you're getting. So the correct version of this would be:
Code:
if ($gameActors.actor(1).equips()[0] && $gameActors.actor(1).equips()[0].id === 42)
I was to use the variable command and set the variable to the id of the armour equipped
However, because the game has hats, tops, leggings and boots how can I check for a specific hat equipped because 4 armour would be equipped at once right? so it can't set the variable to 4 different types of armour
That's exactly what the 0 in the brackets is doing, you're checking a specific equipment slot. Now it doesn't look like the right slot, by default - go to your database and look at the Types tab, then look all the way to the right where it says equipment types. That's the order that your equipment is listed in the array that you're getting from equips. The default for head is slot 2, not 0.

Incidentally, if you're just checking that value to see if they're wearing a specific hat, why would you set it to a variable?

However, you can do this even more efficiently with just one function, which I found from Googling "RPG Maker MV check equipped armor":
Code:
$gameActors.actor(1).isEquipped($dataArmors[helmetID])

where the 1 is the ID of the actor you're looking at, and the helmetID is the ID of the helmet you want to check for (looks like 42, in your case).
 
Last edited:

petpous

Villager
Member
Joined
Apr 25, 2021
Messages
23
Reaction score
1
First Language
English
Primarily Uses
RMMV
So these scripts didn't work for me, I'm not sure why?
But I found another script and I can verify it worked
JavaScript:
$gameParty.isAnyMemberEquipped($dataArmors[13])
13 is the ID of the armour in the database in the list of armour and I put it in a conditional branch. However, the only downside is that it won't check the particular party member
BUT! For me, I actually don't want it to be a specific party member so this saves time.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
1,159
Reaction score
636
First Language
English
Primarily Uses
RMMV
Well, at least in this thread you never said exactly what you wanted to accomplish, so I was just fixing what you posted originally :wink: I definitely recommend you do some basic JavaScript tutorials so that you have some ability to understand what the functions are doing - right now you're kind of grabbing at things in the dark and hoping they work.

I'm glad you found a solution that works for you. Good luck with your game!
 

petpous

Villager
Member
Joined
Apr 25, 2021
Messages
23
Reaction score
1
First Language
English
Primarily Uses
RMMV
Yeah, I'm sorry, I should actually try and learn javascript. I am trying to do something really odd like normal. I have 1 more question so where you have ($dataArmors[13])
Is it possible to make 13 be the value of a variable so ($dataArmors[ whatever variable 90 currently is equal to? ]
I've seen this $gameVariable.value before but clearly I don't know much about javascript so idk
 

ScorchedGround

Blizzards most disappointed fan
Veteran
Joined
Apr 12, 2020
Messages
538
Reaction score
751
First Language
German
Primarily Uses
RMMV
($dataArmors[gameVariables.value(X)])

replace the X with the ID of the variable.
 

ScorchedGround

Blizzards most disappointed fan
Veteran
Joined
Apr 12, 2020
Messages
538
Reaction score
751
First Language
German
Primarily Uses
RMMV
@petpous

Oh sorry, I forgot the "$".

Try ($dataArmors[$gameVariables.value(X)]) instead.
 

Latest Threads

Latest Posts

Latest Profile Posts

For a long time I always consider XP soundtracks as the best one.
Just listened to some of MZ tracks from the free version.
It's... Quite mindblowing. xD
Only listened to the battles, towns, and fields.
But I'm sure the rest are equally good. :D
What do you guys want to see for the new Jump into Javascript? A continuation of the rpg_objects, or would you prefer a "lesson 0" where I go back to the absolute basics of Javascript and cover the fundamentals of the language and its construction?
Hey RPG members!!

How do you finish projects? Some new game developers start off strong but end up losing momentum. What keeps you motivated while working on new projects?
Feeling wee sleepy.. ZzzZ
So many threads to move to the right place. My post count is awesome, but 95% of it is due to moving things.

Forum statistics

Threads
112,452
Messages
1,068,379
Members
146,106
Latest member
sleymour
Top