MV Plugin Command -> JS Eval/Scriptcall?

So I need to use this plugin command ("switch_inventory NAME") from HIME_MultipleInventories. However, I'm trying to make it so when you select the "Inventory" button on the main menu, the game will then execute "switch_inventory NAME" upon selecting an actor (immediately after selecting "Inventory"), where "NAME" would depend on the actor selected. I was thinking of putting the plugin command in YEP_MainMenuManager, under "Actor Bind". What do I need to do in order to get this function working? Thx.
This plugin, right?
Typically plugin commands run through an interpreter; I think for this kind of thing it's simpler to duplicate the script behind the command. 🙂

In this case, looking at Hime's plugin, that seems nice and easy:
JavaScript:
$gameParty.switchInventory(id);
@caethyril Awesome, that seems to be what I was looking for. Now I can only hope that my envisioned solution will work lol.

Edit: Is there a way I can get "id" in $gameParty.switchInventory(id); to equal the actor or party member id (from main menu -> inventory -> select character). Basically the "Actor Bind" thingy. I'm also guessing I might need something like: $gameParty.members().indexOf($gameActors.actor(ACTORID))?

Edit2: How do I get $gameParty.switchInventory(id) & this.commandItem.bind(this) in a single line so I can put them in the "Actor Bind" box?
Edit: Is there a way I can get "id" in $gameParty.switchInventory(id); to equal the actor or party member id (from main menu -> inventory -> select character). Basically the "Actor Bind" thingy.
Untested, but try this:
JavaScript:
$gameParty.switchInventory($gameParty.menuActor()._actorId)
(Note to self: referring to this old "party banter" post.)

Edit:
Edit2: How do I get $gameParty.switchInventory(id) & this.commandItem.bind(this) in a single line so I can put them in the "Actor Bind" box?
Try using a comma , or semi-colon ; between the two statements:
JavaScript:
$gameParty.switchInventory($gameParty.menuActor()._actorId), this.commandItem.bind(this)
If you're using bind then you might need to bind the switchInventory call as well, not sure. 😴
Hmm, do you know if the "Ext" field is run before or after main/actor bind? Idk if that would help or not, cuz I just noticed that simply trying to use this.commandPersonal.bind(this) fails. I think this is due to inventory being a part of "party" rather than "actor". Is my assumption correct?
If you're using bind then you might need to bind the switchInventory call as well, not sure.
Oof, I have no idea how to do that lol.

Edit: I went ahead and added SceneManager.push(Scene_Item); to the following code:
JavaScript:
Scene_Menu.prototype.onPersonalOk = function() {
    switch (this._commandWindow.currentSymbol()) {
    case 'item':
        SceneManager.push(Scene_Item);
        break;
    case 'skill':
        SceneManager.push(Scene_Skill);
        break;
    case 'equip':
        SceneManager.push(Scene_Equip);
        break;
    case 'status':
        SceneManager.push(Scene_Status);
        break;
    }
};

But, it still doesn't work...like I can't even get to the inventory scene.

I've also tried adding SceneManager.push(Scene_Item); to YEP_MainMenuManager's "onPersonalOk" function, to no avail...
Yea, ignore the Ext field. Try this:
  • Main Bind - start actor selection:
    JavaScript:
    this.commandPersonal.bind(this)
  • Actor Bind - process actor selection:
    JavaScript:
    $gameParty.switchInventory($gameParty.members()[this._statusWindow.index()].actorId()), this.commandItem()
Pretty sure it should work, I checked the actor ID with the console and it seemed OK.

Turns out you can't just use menuActor() because that gets updated after Yanfly's stuff. It's also a bit confusing because Main Bind is evaluated to produce a function when the menu loads, but Actor Bind is evaluated at the point of selection... 😴

bind is a method that returns a function bound to a specific context, i.e. it's used to set this to a specific reference. Handy for callbacks like this because the callback is typically defined on a different object (e.g. a scene method called from a selectable window). Details here in case you're interested~
Yea, ignore the Ext field. Try this:
  • Main Bind - start actor selection:
    JavaScript:
    this.commandPersonal.bind(this)
  • Actor Bind - process actor selection:
    JavaScript:
    $gameParty.switchInventory($gameParty.members()[this._statusWindow.index()].actorId()), this.commandItem()
Pretty sure it should work, I checked the actor ID with the console and it seemed OK.

Turns out you can't just use menuActor() because that gets updated after Yanfly's stuff. It's also a bit confusing because Main Bind is evaluated to produce a function when the menu loads, but Actor Bind is evaluated at the point of selection... 😴

bind is a method that returns a function bound to a specific context, i.e. it's used to set this to a specific reference. Handy for callbacks like this because the callback is typically defined on a different object (e.g. a scene method called from a selectable window). Details here in case you're interested~
Yay, it works! Thank you so so much!😊

Original thread: https://forums.rpgmakerweb.com/threads/plugin-command-js-eval-scriptcall.129392/