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

Hey everyone, we know that the edit bar is missing. We're working on it. You can talk about it in the announcement here: https://forums.rpgmakerweb.com/index.php?threads/forum-errors-missing-edit-bar-etc.132715/
So, explain why we can no longer use BBC code or smilies in our posts? This sparks much sadness...
Are we now stuck with WYSIWYG ? I cannot revert back my posts to good old raw text ?
I'm wondering if I may be putting too many things into one map. A story, within a story, within a story . . . it's fun, but I can't shake the feeling that it may be better to scrap some of it, and use it for another map. I'm not sure what to do.

Forum statistics

Threads
107,789
Messages
1,032,209
Members
139,939
Latest member
Mineformer
Top