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

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,506
Reaction score
1,104
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
150
Reaction score
94
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,506
Reaction score
1,104
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
150
Reaction score
94
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,506
Reaction score
1,104
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
60
Reaction score
47
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
71
Reaction score
18
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,506
Reaction score
1,104
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!
 

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

Latest Threads

Latest Posts

Latest Profile Posts

working hard working hard working hard >:)
Do you have an audio you want me to animate? If so send me the youtube link and I’ll animate it.
Okay, so I'm working on Draft 2 of my game's script.
Will try to keep you guys posted, if you're interested!

This is vid of my new game, Crystalgazers. A demo is available on my Gamejolt

I just thought of the best achievement for my game: "'I Didn't Know You Were a Developer!' Find and enter one or more dev room(s)."

Forum statistics

Threads
105,593
Messages
1,014,856
Members
137,257
Latest member
Kalamar_Sinn
Top