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
634
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
634
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
532
Reaction score
746
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
532
Reaction score
746
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

DarkAdria wrote on  Masked 's profile.
Hello, sorry to bother you. I have tried to send you a private message, but it indicates that due to the privacy settings it is not possible.
Some time ago, I finished my project and made a port for Android. Because the original idea was to play the game with a keyboard on PC, playing it with a mouse caused some bugs. (max 420 characters)...
Another day, Another migraine, I found out that the game is broken about the .... Stuff.... Im not best at coding and, I got this billion error, so no choice, I think the error is from Yanfly's SkillMastery...... Fixing it...
Today I got my first shot of the COVID vaccine (Sputnik V). I was very worried. I didn't feel the prick at all. I do not observe any side effects yet.
I should stop staring at the screen too long. neck hurt

Forum statistics

Threads
112,383
Messages
1,067,954
Members
146,035
Latest member
dragonspeedx
Top