RMMV Plugin Command -> JS Eval/Scriptcall?

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,626
Reaction score
1,196
First Language
English
Primarily Uses
RMMV
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.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,118
Reaction score
1,526
First Language
EN
Primarily Uses
RMMZ
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);
 

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,626
Reaction score
1,196
First Language
English
Primarily Uses
RMMV
@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?
 
Last edited:

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,118
Reaction score
1,526
First Language
EN
Primarily Uses
RMMZ
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. :kaoslp:
 
Last edited:

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,626
Reaction score
1,196
First Language
English
Primarily Uses
RMMV
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...
 
Last edited:

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,118
Reaction score
1,526
First Language
EN
Primarily Uses
RMMZ
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... :kaoslp:

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~
 

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,626
Reaction score
1,196
First Language
English
Primarily Uses
RMMV
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... :kaoslp:

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!:kaoblush:
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,051
Messages
1,018,549
Members
137,837
Latest member
Dabi
Top