RMMV How do I delete this line? (Yanfly plugins)

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,846
Reaction score
1,600
First Language
English
Primarily Uses
RMMV
So in my game's inventory page, every item has a the "Use" option on the 1st line. My question is, how do I remove this if it's grayed out (i.e. the item has no use function). I'd like to dig into the JS and add in a conditional so that the "Use" command doesn't appear if it's grayed out. I believe it would have to do w/ YEP_ItemCore, otherwise maybe YEP_EquipCore?

Screenshot:
1603779187382.png

So I found this snippet in YEP_ItemCore.js...but what should I put for the conditional?
JavaScript:
Window_ItemActionCommand.prototype.makeCommandList = function() {
    if (!this._item) return;
    this.addUseCommand();
    this.addCustomCommandsA();
    this.addCustomCommandsB();
    this.addCustomCommandsC();
    this.addCustomCommandsD();
    this.addCustomCommandsE();
    this.addCustomCommandsF();
    this.addCancelCommand();
};
 
Last edited:

coyotecraft

Veteran
Veteran
Joined
Mar 13, 2012
Messages
152
Reaction score
95
First Language
English
Primarily Uses
JavaScript:
 //this.addUseCommand();
You can try commenting out lines with //
You don't have to delete anything. And can easily reinstate it if it doesn't have the desired effect.

Edit:
Ah, but I imagine that'll remove "use" for all items, not just weapons.
There's probably a property category to distinguish key items from other items. So you could add an if statement like
JavaScript:
if (!this._weapon){this.addUseCommand()};
which, I'm just pretending that ._weapon is a property, would add "use" to everything except weapons types.
And if you have specific items that you may want "use" you could made an exception list based on IDs.
 
Last edited:

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,846
Reaction score
1,600
First Language
English
Primarily Uses
RMMV
There's probably a property category to distinguish key items from other items. So you could add an if statement like
My thoughts exactly, I just don't know the correct terminology to make the conditional work. However, it would be better to check if the item in question has a "use" function to begin w/ than to check if the item is an armor or weapon.
 

coyotecraft

Veteran
Veteran
Joined
Mar 13, 2012
Messages
152
Reaction score
95
First Language
English
Primarily Uses
I believe there is a method
JavaScript:
if (DataManager.isWeapon(this) = false) {add the thing}
But (this) might require a more specific property.
this._item perhaps. I'm just taking shots in the dark.
 

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,846
Reaction score
1,600
First Language
English
Primarily Uses
RMMV
Seems like checking this.isUsableItem() would work: https://kinoar.github.io/rmmv-doc-web/classes/game_item.html
Lol doh, it didn't work. It seemed promising too...
1603782665974.png
JavaScript:
Window_ItemActionCommand.prototype.makeCommandList = function() {
    if (!this._item) return;
    if (this.isUsableItem()) {
        this.addUseCommand();
    }
    this.addCustomCommandsA();
    this.addCustomCommandsB();
    this.addCustomCommandsC();
    this.addCustomCommandsD();
    this.addCustomCommandsE();
    this.addCustomCommandsF();
    this.addCancelCommand();
};
Edit: I've also tried this._item.isUsableItem() to no avail...
Edit2: Eureka! The solution was this:
JavaScript:
    if (this._item.isUsableItem) {
        this.addUseCommand();
    }
 
Last edited:

zaraku

Time Keeper
Veteran
Joined
Apr 19, 2018
Messages
70
Reaction score
64
First Language
English
Primarily Uses
RMMV
Lol doh, it didn't work. It seemed promising too...
View attachment 165536
JavaScript:
Window_ItemActionCommand.prototype.makeCommandList = function() {
    if (!this._item) return;
    if (this.isUsableItem()) {
        this.addUseCommand();
    }
    this.addCustomCommandsA();
    this.addCustomCommandsB();
    this.addCustomCommandsC();
    this.addCustomCommandsD();
    this.addCustomCommandsE();
    this.addCustomCommandsF();
    this.addCancelCommand();
};
Edit: I've also tried this._item.isUsableItem() to no avail...
My bad, "this" has a different context in this case because it's being used in a window, so the proper code would be this._item.isUsableItem(). However, looking into the isUsableItem function, it returns true if the object is a skill or an item, which doesn't really narrow down addUseCommand() by much.

Instead, you can try "$gameParty.canUse(this._item)" and hopefully it'll keep it down to consumables/usable skills.
 

Pootscooter

Veteran
Veteran
Joined
Jun 7, 2020
Messages
116
Reaction score
63
First Language
Mandarin
Primarily Uses
RMMV
Edit2: Eureka! The solution was this:
JavaScript:
if (this._item.isUsableItem) {
this.addUseCommand();
}
Interesting how removing the parenthesis after "isUsableItem" fixed it lol. GJ!
 

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,846
Reaction score
1,600
First Language
English
Primarily Uses
RMMV
Actually, my previous post was flawed. The correct way to implement it is this:
JavaScript:
Window_ItemActionCommand.prototype.makeCommandList = function() {
    if (!this._item) return;
    if ($gameParty.canUse(this._item)) {
        this.addUseCommand();
    }
    this.addCustomCommandsA();
    this.addCustomCommandsB();
    this.addCustomCommandsC();
    this.addCustomCommandsD();
    this.addCustomCommandsE();
    this.addCustomCommandsF();
    this.addCancelCommand();
};
It works perfectly!
 

Latest Threads

Latest Posts

Latest Profile Posts

>Testing with fonts change.
>Tries installing a plugin. Doesn't work.
>Tries changing the plugin commands. Doesn't work.
>Tries installing another plugin. Doesn't work.
>Changes a few more plugin commands. Doesn't work.
>Goes directly to the gamefont file and changes the src. Works.

YYEEEAAAAHHHAAAA

Perseverance is key, bois and girls.
What Reviews say on RPG Maker MZ?
Looking back at some sketches, and game design documents on my PC dated summer of 2015. I started development with the release of MZ, but in 2015, I felt a strong desire to make a game out of the blue. I remember feeling sad for no apparent reason, and all these ideas rushed into my head. Now that I think about it, since that day, everything has become easier to do on my PC . . . it’s very creepy.
Everything's going to be alright! We're all in this together. <3
Aaaaannd published my game's tech demo. :D

Feel free to download and play it. And give feedback!

Forum statistics

Threads
107,802
Messages
1,032,317
Members
139,946
Latest member
Yatsekonn
Top