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.
MV Plugin Command -> JS Eval/Scriptcall?
Javascript/Plugin SupportThis plugin, right?
forums.rpgmakerweb.com
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:
Multiple Inventories
Ever needed to manage multiple inventories? For example, you have two actors in your game, but they are in two different locations. To make this more realistic, you would like each actor to have their own inventories, such as their own weapons, armors, items, and gold. This plugin provides...
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
Edit2: How do I get
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?Untested, but try this:
JavaScript:
$gameParty.switchInventory($gameParty.menuActor()._actorId)
Edit:
Try using a comma
, or semi-colon ; between the two statements:
JavaScript:
$gameParty.switchInventory($gameParty.menuActor()._actorId), this.commandItem.bind(this)
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
Edit: I went ahead and added
But, it still doesn't work...like I can't even get to the inventory scene.
I've also tried adding
this.commandPersonal.bind(this) fails. I think this is due to inventory being a part of "party" rather than "actor". Is my assumption correct?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:
Turns out you can't just use
developer.mozilla.org
- 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()
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~Function.prototype.bind() - JavaScript | MDN
The bind() method of Function instances creates a new function that, when called, calls this function with its this keyword set to the provided value, and a given sequence of arguments preceding any provided when the new function is called.
Yay, it works! Thank you so so much!😊
Original thread: https://forums.rpgmakerweb.com/threads/plugin-command-js-eval-scriptcall.129392/