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

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,529
Reaction score
1,112
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,529
Reaction score
1,112
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,529
Reaction score
1,112
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
73
Reaction score
19
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,529
Reaction score
1,112
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 Profile Posts

Yet another gaming question, i'm currently playing Last of Us 2 and want to get another game to play next but can't decide between Ghost of Tsushima, Miles Morales & Jedi Fallen Order. After the latest mandalorian i AM on a star wars kick, but i also LOVED the last spiderman game that prequels Miles Morales. Ghost of Tsushima is the bottom of my list but i heard it was AWESOME. Just want a good story & fun gameplay.
I checked out Genshin Impact gameplay out of curiosity. I can't believe it's available as a mobile game too. Smooth animation, great music, and stellar sound effects (the ambient sounds are pretty detailed).

I'm flabbergasted to see games have becoming more and more advanced. Maybe also because I'm oblivious to current trend for a long time, it almost feel like I'm being sent into distant future. xD
xDRAGOONx wrote on WaywardMartian's profile.
Your artwork is amazing!!!
:ewat:
Stream will be live shortly with a session of the Interactive Text Adventure! Feel free to drop by!
I should finish the cat video I'm editing and finish the indesign stuff. So far only 1 is done and 4 to go

Forum statistics

Threads
105,665
Messages
1,015,382
Members
137,341
Latest member
jasapembuatanwebsite
Top