Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,711
Reaction score
2,822
First Language
English
Primarily Uses
RMMZ
When you get a "Cannot read property 'x' of undefined" error, it means that the code is attempting to access something on an object that doesn't exist.

Like if I put $gameParty.members()[3].hp in a notetag and I only had 2 people in the party, I'd get "Cannot read property 'hp' of undefined" because there would be no party member in that index to access the hp property of.

It's more often than not caused by improper syntax in a notetag or not checking that an object exists prior to using its properties.

ES6 actually added a really handy null-chaining operator which largely negates this problem: now you can do something like $gameParty.members()[3]?.hp and it'll elegantly return null if the object doesn't exist instead of causing an error.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
33,371
Reaction score
8,392
First Language
German
Primarily Uses
RMMV
As trihan already explained it is easy to see and explain that this is caused by a missing data object, but determining which object is missing and why is a lot more difficult.

He listed some possibilities, but there are others that can cause exactly the same type of error:
1) loading an older and now incompatible savefile
2) deleting an object in the database that is still referenced somewhere (like deleting a class that is still used by an actor)
3) a plugin configuration telling the plugin to access an object that does not exist (like saying "the actor ID4 should always be in first position on a formation" and then only having three actors in the project.

I think you get the point and the problem - how do you find out what does not exist if all you get is "of undefined" or "of null".
A full errortrace and the name of the property can give some points to what it might be, like HP pointing to an actor or enemy problem, but unfortunately I do not have any idea what kind of property that "list" is. Perhaps a screenshot of the full error trace might help?
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,711
Reaction score
2,822
First Language
English
Primarily Uses
RMMZ
Yeah, we'll definitely need to look at the stacktrace to figure out the root cause.
 

Indinera

Indie Dev
Veteran
Joined
Mar 13, 2012
Messages
2,057
Reaction score
855
First Language
French
@Trihan "ES6" looks great but what is it and more importantly where can I find it?

@Andar do you mean this?
(more background about the error message: from what I've observed it happens after defeating an enemy and I have a big common event running at that specific moment - that said it also seems to happen a bit randomly, sometimes with the exact same fight... I'll reread the common event in question to try and see if something jumps to me - any suggestion welcome of course!)

error2.png
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
33,371
Reaction score
8,392
First Language
German
Primarily Uses
RMMV
do you mean this?
no, the console output instead of the element list (look at what tab is selected at the top of the window
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,711
Reaction score
2,822
First Language
English
Primarily Uses
RMMZ
@Trihan "ES6" looks great but what is it and more importantly where can I find it?

@Andar do you mean this?
(more background about the error message: from what I've observed it happens after defeating an enemy and I have a big common event running at that specific moment - that said it also seems to happen a bit randomly, sometimes with the exact same fight... I'll reread the common event in question to try and see if something jumps to me - any suggestion welcome of course!)

View attachment 192081
ES6 = ECMAScript 6. It's just the current Javascript version. You don't need to do anything to use it; the ES version being used by MZ is determined by the node.js version, and the one being used by the latest update supports ES6, so you can use null-chaining operators in your script calls.

(it also added null-coalescing assignment: you can now do something like "const var ??= 5;" and it will either assign it the value 5 or return itself if it already exists. It's the equivalent of "const var = var || 5")
 

Indinera

Indie Dev
Veteran
Joined
Mar 13, 2012
Messages
2,057
Reaction score
855
First Language
French
so you can use null-chaining operators in your script calls.

How do I do that with the common event that apparently sometimes generates the error message?
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,711
Reaction score
2,822
First Language
English
Primarily Uses
RMMZ
Okay, so the "list" it's referring to in that error is the property of a game event page containing the commands inside it. So it's trying to access an event page that isn't there. What is calling the common event?

Edit: actually looking at the call stack this appears to be an event that triggered on player touch that's causing the issue?
 

Indinera

Indie Dev
Veteran
Joined
Mar 13, 2012
Messages
2,057
Reaction score
855
First Language
French
1623488638400.png

C.ev. "Enter the F" is actually empty. I had put it there in case I'd need something before the battle occurs.
C.ev. "Win" is the big one. It does a lot of things for sure but I can't quite pinpoint what would be the problem about it. It's also not like the error message happens often.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
33,371
Reaction score
8,392
First Language
German
Primarily Uses
RMMV
as a more general advice about reading error backtrace, you can read the names of all javascript files involved in the error. The default engine files will almost always be there, but it will also list the plugins that are involved - and that is usually a great help.

In this case it is the visustella move core and galv's diagonal movement.
That points out that it is something with the event movement on the map directly after the battle, and what I especially find strange is that <computed> as part of the data structure in several lines.

could it be that one of the plugins artificially generated either an event or a command list for an event and the other plugin accidentially deletes it in some cases?

EDIT: ninja'd
but it seems that the problem is something tries to access that event after it has been deleted by erase event. most likely the approach autonomous movement would be my guess as that would fit with the plugin names mentioned above
 

Indinera

Indie Dev
Veteran
Joined
Mar 13, 2012
Messages
2,057
Reaction score
855
First Language
French
could it be that one of the plugins artificially generated either an event or a command list for an event and the other plugin accidentially deletes it in some cases?

From what I can understand, it doesn't seem like it.
The c.ev. uses a lot of variables but has no events related to move whatsoever.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
33,371
Reaction score
8,392
First Language
German
Primarily Uses
RMMV
I edited my post above while you answered
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,711
Reaction score
2,822
First Language
English
Primarily Uses
RMMZ
as a more general advice about reading error backtrace, you can read the names of all javascript files involved in the error. The default engine files will almost always be there, but it will also list the plugins that are involved - and that is usually a great help.

In this case it is the visustella move core and galv's diagonal movement.
That points out that it is something with the event movement on the map directly after the battle, and what I especially find strange is that <computed> as part of the data structure in several lines.

could it be that one of the plugins artificially generated either an event or a command list for an event and the other plugin accidentially deletes it in some cases?

EDIT: ninja'd
but it seems that the problem is something tries to access that event after it has been deleted by erase event. most likely the approach autonomous movement would be my guess as that would fit with the plugin names mentioned above
Which is perplexing, because erase event doesn't actually erase the event; it just sets an "erased" flag on the event object to true.
 

Indinera

Indie Dev
Veteran
Joined
Mar 13, 2012
Messages
2,057
Reaction score
855
First Language
French
I removed Galv's plugin. Visu seems to have the diagonal moves anyway.
But unfortunately and much to my disappointment, the error message still occured.

error4.png
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,711
Reaction score
2,822
First Language
English
Primarily Uses
RMMZ
Do you know how to set a breakpoint? You might have to pause execution and step through the code to find where it's failing.
 

Indinera

Indie Dev
Veteran
Joined
Mar 13, 2012
Messages
2,057
Reaction score
855
First Language
French
Do you know how to set a breakpoint?

Probably not in a competent way.
Can you please tell me how? I would generally just insert a dialogue and see if the error message occurs after it or before it...
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
33,371
Reaction score
8,392
First Language
German
Primarily Uses
RMMV
because erase event doesn't actually erase the event; it just sets an "erased" flag on the event object to true.
in that case it could be that <computed> idea I had before seeing the erase command (before the edit add-on in the post I made).
or do you know how that part of the data structure is created? because it doesn't fit with the regular naming conventions of the default engine...
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,711
Reaction score
2,822
First Language
English
Primarily Uses
RMMZ
When you get the error, if you look at the stacktrace each line is a clickable link. If you click the most recent line, it will take you to the "sources" tab to the line of code that caused the error. You can then click in the left margin to put a breakpoint on that line. Close the game and rerun it, and when it reaches that line instead of erroring out it'll pause, and you can examine objects with context highlighting and step through code line by line if necessary. It'll allow you to see whether it's the event itself that doesn't exist, or the page, or something else. And then you can step backwards from there if you need to if you can't find the problem at that point.
 

Latest Threads

Latest Posts

Latest Profile Posts

Finally, deleted my Reddit account
I cant say I dont regret it, I honestly liked FMA subreddit, but nah, reddit succs
Ami
need a time to not open my MV,still addicted with new vegas

i wonder what addiction effect behind playing new vegas too much,maybe INT & Science gone worse in many days :D
cdjensen94 wrote on Kaliya's profile.
Are you the one who develops Kaliya's Visual Map Enhancements. If so I desperately need some help. I bought the plugin back a few months. I've only started using it recently.
Cause MP Damage instead of HP, Localization Plugin for Translation | RPG Maker News #112

Here in Fla were are seeing crazy covid spikes and some vaccinated getting bad infections. I had a mild fever on Thurs but it went down fast. How is everyone else doing. Hopefully you are all well. :)

Forum statistics

Threads
113,833
Messages
1,077,788
Members
147,893
Latest member
2DMike
Top