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,126
Reaction score
614
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,126
Reaction score
614
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
521
Reaction score
733
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
521
Reaction score
733
First Language
German
Primarily Uses
RMMV
@petpous

Oh sorry, I forgot the "$".

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

Latest Threads

Latest Profile Posts

Sometimes you Just need to realise someone is beyond help... Still hard to walk away tho :(
100 Horror/Tragedy Sample Maps, Penguin Mech Sprite, & TileD Templates | RPG Maker News #70

Continuing working on abs. So far I have done the workout twice. I am excited to see the results after a couple of weeks. How is everyone doing? :)
MZ: oh boy imma work today
Me, excited: Really?
MZ, doesn't do what I tell It too
Me: I Thought-
MZ: I am Working!
Oof, this "side project" of mine is starting to get as complex as a VS plugin, at least as far as plugin parameters are concerned. I think I now understand why a plugin like this doesn't already exist(that I know of). Learning a lot while trying to make it work though!

Forum statistics

Threads
112,215
Messages
1,066,598
Members
145,821
Latest member
Adra
Top