MenuSubCommand by Triacontane and Custom Help Window script help

Hey ya'll. Just me again.

I've modified a SumRndmDde alt menu script with a menu help window tutorial by CodeBreakerZ and it works great, for the most part.

I'm also using a plugin by Triacontane that adds submenu command windows. I have a "settings" menu command that opens up a new small window with "options," "load," and "quit."

Anyways, the CodeBreakerZ help window shows descriptive strings based on what command/selection the cursor is on. It works for all of my menu commands except for the commands in the submenu. I've tried a few things and no luck, so I don't know if it's a more complicated code process than what's used for typical menu commands.

Here's a link to his tutorial for anyone interested:
Spoiler: Link


On a side note, I'm not sure how to make the help window display skill category info, since it'll be different per actor and I'm not quite sure how to set the code to know what to write out in the help window. But that's a secondary concern for now.

I'm not sure if anyone will be able to test it in game since these scripts have been customized to my project, but maybe those who can read the .js will be able to figure it out.

Thanks for the help!
Before sharing plugins, always check the license. For example SumRndmDde has
You are NOT allowed to redistribute these Plugins.
in his terms of use.

Triacontane is MIT, so I presume that should be fine.
Anyway, back to business:
I've tried a few things and no luck, so I don't know if it's a more complicated code process than what's used for typical menu commands.
It is not a complicated process. However, take a look at what you did.
Code:
Scene_Menu.prototype.update = function () {
            Scene_MenuBase.prototype.update.call(this);
            if (this._subMenuWindow.active) {
                this._helpWindow.setText(subComHelp[this._subMenuWindow._index]);
            }
        }

    Scene_Menu.prototype.update = function() {
        Scene_MenuBase.prototype.update.call(this);
        this._helpWindow.setText(allHelp[this._commandWindow._index]);
    }
You defined Scene_Menu.prototype.update... Twice. Which is impossible. Your second definition will kill the first one.
So instead of using two separate definitions, use one and an else if.
Before sharing plugins, always check the license. For example SumRndmDde has
You are NOT allowed to redistribute these Plugins.
in his terms of use.

Ah shoot, I didn't even realize that counted as redistribution. But I suppose if it's downloadable in any form for any reason, that's redistribution, haha. I'll remove the link! Thanks for the heads up!

You defined Scene_Menu.prototype.update... Twice. Which is impossible. Your second definition will kill the first one.
So instead of using two separate definitions, use one and an else if.

Ok gotcha! That makes sense. I thought I was essentially doing the same as the rest of the conditions for the other scenes, which in a sense I was, except each is only getting defined once, and here I was doing it twice in the menu screen.

Tried it out and it works perfectly! Thank you!

So onto the secondary issue with it. For the Scene_Skill. I can figure this much out:

Spoiler: JS
Scene_Skill.prototype.update = function () {
Scene_ItemBase.prototype.update.call(this);
if (this._categoryWindow.active) {
this._helpWindow.setText(helpSkillCategory[this._categoryWindow._index]);
}
}

But that's referencing an array under the helpSkillCategory variable. The thing is I can't use that since all 4 members have a unique skill-type each, and a secondary one that's the same all around. Would it be just a bunch of if statements? As in if categoryWindow is active and if skill category equals 'this' then setText to the string from a variable? I'm just not sure how to check what skill category is selected.

Any help on that is greatly appreciated, as well!
Yup, that would be it.
If I have a window that can have multiple sets of choices, it's a matter of ifs.

For example: I have 4 actors:
First has skill types: Melee, shield, knight, personal
Second has skill types: Melee, ranged, rogue, personal
Third has skill types: Magic, staff, mage, personal
Fourth has skill types: Heal, staff, healer, personal

Then you can go around it like this:
Code:
var descs = [["Melee skills", "shield skills", "knight skills", "personal skills"], ["Melee skills", "ranged skills", "rogue skills", "personal]]... etc.

if (current actor's class ID is x) this._helpWindow.drawText(descs[0][this._skillWindow.index()];

It's a very rough example, because there are dozens of ways to determine which actor is currently selected, including for example checking the parent window for its index or passing a variable value to the current window upon actor selection.
Awesome! Ok I'll try that out and play around with it and see what I can do. Thanks for the help!
Double-posting here, but here's the script I've got going (help window script only):

Spoiler: Script
var helpItemCategory = ['Your stuff', 'Things that might come in handy later'];
var helpEquipCategory = ['Equip yourself', 'Pick the best', 'Remove all gear'];
var itemHelp = 'Your bag of stuff.';
var skillHelp = 'Your mad skillz.';
var eqHelp = 'Equip yourself.';
var statHelp = 'Your personal deets.';
var optionsHelp = 'System stuff.';
var subComHelp = ['Game settings', 'Load a game file','Quit the game'];
var skillDescs = [["Funky skills", "Superman skills"], ["Danger skills", "Superman skills"], ["AAAW skills", "Superman skills"], ["Nutty skills", "Superman skills"]];
var allHelp = [itemHelp, skillHelp, eqHelp, statHelp, optionsHelp];

Scene_Item.prototype.update = function () {
Scene_MenuBase.prototype.update.call(this);
if (this._categoryWindow.active) {
this._helpWindow.setText(helpItemCategory[this._categoryWindow._index]);
}
};

Scene_Equip.prototype.update = function () {
Scene_MenuBase.prototype.update.call(this);
if (this._commandWindow.active) {
this._helpWindow.setText(helpEquipCategory[this._commandWindow._index]);
}
};

Scene_ItemBase.prototype.createHelpWindow = function() {
this._helpWindow = new Window_Help();
this.addWindow(this._helpWindow);
};

var xSceneMenu_create = Scene_Menu.prototype.create;
Scene_Menu.prototype.create = function() {
xSceneMenu_create.call(this);
this.createHelpWindow();
}

Scene_Menu.prototype.update = function() {
Scene_MenuBase.prototype.update.call(this);
if (this._commandWindow.active) {
this._helpWindow.setText(allHelp[this._commandWindow._index]);
}

else {
* if (this._subMenuWindow.active) {
this._helpWindow.setText(subComHelp[this._subMenuWindow._index]);
}
}
};

Scene_Skill.prototype.update = function () {
Scene_MenuBase.prototype.update.call(this);
** if (this._skillWindow.active) {
if (this._actor.classId = 0) {
this._helpWindow.setText(skillDescs[0][this._skillWindow.index()]);
}
}
};

The strings are all just ridiculous placeholders, haha.

Anyway, what's happening is that when I select anything in the menu command list, I get an error saying "Cannot read property 'active' of undefined" referencing the line with * I highlighted in the script.

If I disable the piece of code about the subMenuWindow, I get an error saying "Cannot read property 'active' of undefined" referencing the line with ** when I select the Skill category (the others work fine, just no help being displayed since it's all been disabled).

The same thing as above happens when I disable the trial Scene_Skill code bit, referencing * as 'active' being undefined when I select any of the menu commands.

So I'm not sure what's up since "active" is being used elsewhere in the code and works fine, like in Scene_Item and Scene_Equip. I noticed these errors when I began working on the help window for Scene_Skill.
When the error sounds
"Cannot read property 'active' of undefined"
and it points to
this._subMenuWindow.active

then logically this._subMenuWindow is undefined, meaning it hasn't been instantiated. Either it's a non-existent window or it has a different variable name. Check out if or when this window gets created in the code.
Hmmm... I wondered about that, but the window appears how it should when I activate the Options command in the main menu. I was assuming this._subMenuWindow was being defined in the Menu Sub Command plugin. So it only shows the error when I'm switching to a new scene. Would that mean the new scenes being opened are expecting the subMenuWindow to be in them, too? As well, the error will say 'null' rather than 'undefined' if I had activated the Options menu, thus opening the subcommand window, before selecting a different command from the command menu.

But after about an hour and a half of fumbling around, maybe I'll abandon the submenu idea and add what I had there to the options scene.

Still working on the script for the help content in the skill menu. I've got this:
Spoiler
Scene_Skill.prototype.update = function () {
Scene_MenuBase.prototype.update.call(this);
if (this._skillTypeWindow.active) {
if (this._actor.classId = 1) {
this._helpWindow.setText(skillDescs[0][this._skillTypeWindow.index()]);
}
else if (this._actor.classId = 2) {
this._helpWindow.setText(skillDescs[1][this._skillTypeWindow.index()]);
}
else if (this._actor.classId = 3) {
this._helpWindow.setText(skillDescs[2][this._skillTypeWindow.index()]);
}
else if (this._actor.classId = 4) {
this._helpWindow.setText(skillDescs[3][this._skillTypeWindow.index()]);
}
}
};

It works sort of, in the sense that it's displaying class ID 1's information, but for all characters, haha. I'm wondering if I'm missing some kind of refresh or update, but by looking at it, it appears as though it SHOULD work. I'm fresh out of ideas as to why it isn't, haha.
So it only shows the error when I'm switching to a new scene. Would that mean the new scenes being opened are expecting the subMenuWindow to be in them, too?
Of course it does. Where there's nothing, even death can't take from. There's a simple fix though.
Code:
if (this._subMenuWindow) {
if (this._subMenuWindow._active)
your code

I'm wondering if I'm missing some kind of refresh or update, but by looking at it, it appears as though it SHOULD work.
It doesn't.
if (this._actor.classId = 1)
You're performing a = , which is value assignment instead of == "is equal to".
Naturally value assignment returns the assigned value, so unless you're assigning a falsey value, it always passes the if check.
Of course it does. Where there's nothing, even death can't take from. There's a simple fix though.

Awesome. So then I'd plug that in like:

Code:
Scene_Menu.prototype.update = function() {
     Scene_MenuBase.prototype.update.call(this);
          if (this._commandWindow.active) {
               this._helpWindow.setText(allHelp[this._commandWindow._index]);
               }

         else {

                 if (this._subMenuWindow) {
                        if (this._subMenuWindow._active) {
                        this._helpWindow.setText(subComHelp[this._subMenuWindow._index]);
                        }
                }
        }
};

You're performing a = , which is value assignment instead of == "is equal to".
Naturally value assignment returns the assigned value, so unless you're assigning a falsey value, it always passes the if check.

Ok, yes, that makes total sense. It's ringing some bells from some javascript class I had years ago! Also makes != as "doesn't equal" visual sense if "==" means "is equal to".

I'll play around with these tonight to see what happens!
ALLL RIIIGHHHT! Got it working! I had to do some digging because actor.classId wasn't cutting it. Wasn't really sure why. I think I read that all that returns is a true/false value, but beats me.

However, THIS worked:
Code:
Scene_Skill.prototype.update = function () {
        Scene_MenuBase.prototype.update.call(this);
        if (this._skillTypeWindow.active) {
            if (this._actor.isClass($dataClasses[1])) {
            this._helpWindow.setText(skillDescs[0][this._skillTypeWindow.index()]);
                }
            else if (this._actor.isClass($dataClasses[2])) {
            this._helpWindow.setText(skillDescs[1][this._skillTypeWindow.index()]);
                }
            else if (this._actor.isClass($dataClasses[3])) {
            this._helpWindow.setText(skillDescs[2][this._skillTypeWindow.index()]);
                }
            else if (this._actor.isClass($dataClasses[4])) {
            this._helpWindow.setText(skillDescs[3][this._skillTypeWindow.index()]);
                }
            }      
    };

I was also getting a weird thing where I would open the subMenu then cancel out of it, then select something like skill or equip that would bring the cursor to the actor, then cancel out of that, resulting the in cursor opening the subMenu and going there instead of the command window. Found that to be a problem with the menu sub command plugin itself, so fixed that up, which was a relief and a very satisfying feeling, haha.

What I have now is something minor, using Galv's Animated Cursor, but I can start another thread to address that issue since it's its own thing.

We can consider this threat solved!

Thanks @Poryg for the help and guidance. I greatly appreciate it and you taking the time to do so. Cheers to RPG making!
Well done! If you consider the thread solved, report the first post saying you want it closed.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/menusubcommand-by-triacontane-and-custom-help-window-script-help.105036/