Cannot read property length of undefined. Yanfly MoreStatusPages

● ARCHIVED · READ-ONLY
Started by Jeremiah Eastman 17 posts View original ↗
  1. Hey there gang I am having an issue with a plugin and I believe it may be an easy fix, but beyond my skill level. On Yanflys MoreStatusPages plugin when you are on the added pages if you press page up or page down the game crashes. This happens on a new clean project. I will post a pic of the error, I hope someone can help with this.

    Here's a link to the plugin.
    http://yanfly.moe/2017/06/02/yep-140-more-status-menu-pages-rpg-maker-mv/

    The error seems to point to this line of the code:
    return this._actor.actor().customStatusMenuPagesData[pageKey].length;

    Edit:
    Removing the [pageKey] from the code stops the crash but then the info in the window doesn't show up. I almost thought I had it there.
  2. Please post a link to the plugin so people can look at it without having to go searching.
  3. [move]Javascript/Plugin Support[/move]
  4. Ms Littlefish said:
    [move]Javascript/Plugin Support[/move]
    Dang I am sorry, I am really blowing it today. Hate to be a problem.
  5. No worries at all! Blue text is just a reminder. It happens!
  6. @Jeremiah Eastman
    I didn't actually test this, this is just an assumption.
    Copy this into a new .js file, import it as a plugin and place it BELOW YEP_X_MoreStatusPages.

    Code:
    Window_StatusInfo.prototype.maxItems = function () {
       var actor = this._actor ? this._actor.actor() : null;
       if (this._symbol === 'morePages' && actor && actor.customStatusMenuPagesData && actor.customStatusMenuPagesData[pageKey]) {
           var pageKey = SceneManager._scene._commandWindow.currentExt();
           return actor.customStatusMenuPagesData[pageKey].length;
       } else {
           return Yanfly.MSMP.Window_StatusInfo_maxItems.call(this);
       }
    };
  7. waynee95 said:
    I didn't actually test this, this is just an assumption.
    Copy this into a new .js file, import it as a plugin and place it BELOW YEP_X_MoreStatusPages.

    Code:
    Window_StatusInfo.prototype.maxItems = function () {
        var actor = this._actor.actor();
        if (this._symbol === 'morePages' && actor && actor.customStatusMenuPagesData) {
            var pageKey = SceneManager._scene._commandWindow.currentExt();
            return actor.customStatusMenuPagesData[pageKey].length;
        } else {
            return Yanfly.MSMP.Window_StatusInfo_maxItems.call(this);
        }
    };
    Hey bud, thanks for the reply. I really appreciate the code but there does seem to be an issue. At the start the debug console reads:
    SyntaxError: Unexpected token ]

    Then if I try to load in and go to the extra window it crashes with.

    TypeError: Cannot read property 'actor' of undefined
    at Window_StatusInfo.maxItems (Fix.js:2)
    at Window_StatusInfo.Window_Selectable.maxRows (rpg_windows.js:779)
    at Window_StatusInfo.Window_Selectable.maxTopRow (rpg_windows.js:817)
    at Window_StatusInfo.Window_Selectable.setTopRow (rpg_windows.js:821)
    at Window_StatusInfo.Window_Selectable.ensureCursorVisible (rpg_windows.js:1225)
    at Window_StatusInfo.Window_Selectable.select (rpg_windows.js:795)
    at Window_StatusInfo.Window_Selectable.reselect (rpg_windows.js:805)
    at Window_StatusInfo.Window_Selectable.deactivate (rpg_windows.js:789)
    at Window_StatusInfo.Window_Selectable.initialize (rpg_windows.js:734)
    at Window_StatusInfo.Window_Selectable.initialize (SRD_SuperToolsEngine.js:3065)rpg_managers.js:1950 SceneManager.catchExceptionrpg_managers.js:1911

    I don't think I can just remove the ] this time.:smile:
  8. I changed the code above.
  9. waynee95 said:
    I changed the code above.
    Dang, unfortunatly almost the same crash.:frown: But this time its mentioning the max items rather than actor. I'll post a pic.

    upload_2017-8-21_14-3-8.png
  10. Download it again from Yanfly's site, the problem is that the YEP_X_MoreStatusPages isn't loading because of a syntax error.
  11. Dang yeah that was the syntax issue. Thanks much bud. I hate to say it though but it seems like the original issue is still happening however. I'll post a pic.

    Edit:
    The Fix file in the pic is the code from you.
    upload_2017-8-21_14-11-30.png
  12. Okay, changed it again.

    If that still leads to an error, then you might have the More Pages setup wrongly.
  13. Yeah still getting an error but it's different now. But also with the patch code I noticed only the first line of info shows in the new window from the plugin. When I turned off the patch it displayed properly. I am testing it on a blank project, I went over everything again and it seems to be set up properly. Everything works fine except for the page keys. I really do appreciate your help. Even though we didn't get it fixed you still rock Waynee.:smile:

    I'll go ahead and toss up the new error just in case:
    upload_2017-8-21_14-40-27.png
  14. Maybe you'll want to report it as a bug, if it happens even in brand new projects.

    Edit: It is probably a bug. It calls a function SceneManager._scene._commandWindow.currentExt(), but currentExt is not defined anywhere. I've seen several mentions in the core script, but definition was nowhere to be found. If you copy paste this into th And even google won't help me with currentExt.
    Also, the thing is, if the function is defined, input into console should make it visible (since the first thing an interpreted language does is interpret functions). However, if I copy paste SceneManager._scene._commandWindow.currentExt() into console, I get null.

    Another edit: Looks like there are actually problems earlier in the code. I'll examine it further.
    Last edit: Nevermind, didn't find the problem. However, I still recommend to take it to Yanfly, because this is a bug.
  15. @Poryg
    The currentExt function is defined inside the Window_Command class. Because the command window of the item scene inherits from Window_Command, it has the currentExt function. CurrentExt is only used in special cases. When you add a command to the command window, you use .addCommand(name, symbol, enabled). But you can also add a 4th parameter .addCommand(name, symbol, enabled, ext). This ext value will be then returned by the .currentExt() function, if that command has any ext value. Normally the commands don't have an ext value. In the case of the YEP_X_MorePages, the commands for the extra pages will get an ext value.
    PHP:
    Window_StatusCommand.prototype.addMoreStatusMenuPages = function () {
        /* ... */
            var pageKey = order[i];
            if (this.isShowStatusMenuPage(pageKey)) {
                this.addCommand(pageKey, 'morePages', true, pageKey); // <- pageKey is the ext value here
            }
        }
    };
    So when you have a command selected that belongs to a "more pages" and you call Scene._scene._commandWindow.currentExt(), it will print it. At least in theory, but it also works for me.
  16. I'll go ahead and submit an official bug report on yanflys page here. Thanks for all the info you guys, I really appreciate all the help.:smile: