TypeError: Cannot read property '0' of undefined // Help

● ARCHIVED · READ-ONLY
Started by GamGam 4 posts View original ↗
  1. My friend sent me a plugin his friend made last year. It's supposed to the a skill tree plugin, but it's not currently working since a few versions ago. I asked him to see if his friend could fix it, but he hasn't been online for ages.
    Spoiler
    PREVIOUS PROBLEM:
    WjE79y7.png

    Line 125 has this on:
    optAddOnMainMenu: (PluginManager.parameters('trevas skill tree')['OptAddOnMainMenu']).toLowerCase(),

    UPDATE:

    While messing around with it, my friend managed to get somewhere, but now there is another error (The option to the Skill Tree shows up on the menu now as well).

    TBbl2HZ.png
    Line 286: if (this._data[index] != "vazio") {
    Line 281: this.drawAllItems();
    Line 162: this.windowSkillTree.refresh(this.actor());

    My friend asked me not to share the plugin publically so I can't paste it here fully.

    What can be done to fix this error?

    PS: 'vazio' means 'empty' in portuguese
  2. The error is entirely dependent on the context, the data passed to the function, and the call stack.

    Without the source code, no one can suggest a solution.

    The error message states "cannot read property 0 of undefined" which means that 'this._data' is undefined.

    If you cannot share this plugin then I suggest you learn to use the Chrome debugger to step through the code one line at a time to locate the mistake.
  3. The problems reside on sk.js file on lines, 286, 281, 162. Chances are, it is on line 286 where the drawItem is trying to draw from an improper object.
  4. back to the basics -a very simple question just to make sure that you didn't make that mistake:
    have you started a new game after adding this plugin, or did you continue a saved game?

    The error says that data is undefined, and a plugin gets its data defined on "new game". Part of that data is saved into savefiles, but if the plugin had not been added correctly at the moment the save was made, then continuing an older save very often results in these "undefined" errors - simply because the data for the plugin is not yet defined.

    And no, just because you get an error line number that does NOT mean that the error is on that line. Computers and programming doesn't work that way.
    The line numbers you get is where the computer detects the problem, and as aloe guvner said above it is the line where the computer detects "I do not have any data for this._data", this._data is undefined so I cannot check this._data[0] (the first index).

    The entire name for this object "this._data" should indicate even to a non-programmer that "this" is not a direct reference, but an indirect reference to something that could not be given a real name before the code is executed.
    And the definition of "this" is somewhere else, not on the reported lines.

    And if you are not allowed to post the code and the error was not caused by continuing an incompatible savegame, then your only way to proceed is to ask your friend for help (or to ask him for the contact of whichever programmer wrote the plugin)