RMMV Plugin Command -> JS Eval/Scriptcall?

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,499
Reaction score
1,093
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,052
Reaction score
1,481
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,499
Reaction score
1,093
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,052
Reaction score
1,481
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,499
Reaction score
1,093
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,052
Reaction score
1,481
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,499
Reaction score
1,093
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 Posts

Latest Profile Posts

Just finished composing a boss battle theme!
Scripted a multi-variable weather system that randomizes wind speed, cloudiness, rain, fogginess, etc, while attempting to realistically account for interactions between them (e.g. wind speed affects fogginess, cloudiness affects rain, etc), the current weather pattern, and the player's biome e.g. swamp, beach, etc. Now I "just" have to tie visuals and sounds to the variables so stuff actually happens...
I'm having a headache balancing the combat using flat defense so I'm gonna use percentual armor, in this pic, Simon has 16 on Defense which means all the incoming damage will be reduced by 16% this will ease my burden a bit.
!Have a nice day everybody¡
SO glad they patched outer worlds for switch! I can finally play it! Weird that other peeps are still having issues. I know it was really chugging on my lite when it first came out.

Forum statistics

Threads
105,555
Messages
1,014,620
Members
137,231
Latest member
anjing_gila
Top