MZ [SOLVED] How to check if Window_ShopNumber is selling mode or buying mode.

Hey all,

As the title says, I'm looking to check if Window_ShopNumber's contents are to be sold or bought since I would like to add a line of text for buying or selling. I'd also like it to appear in the same line as the item being bought or sold. I figure I could toss an if statement to check in here, which would decide what to write, etc.:

Code:
Window_ShopNumber.prototype.drawCurrentItemName = function() {
    const padding = this.itemPadding();
    const x = padding * 2;
    const y = this.itemNameY();
    const width = this.multiplicationSignX() - padding * 3;
    this.drawItemName(this._item, x, y, width);
};

I'm just not sure how to check the buy/sell mode of the window. As usual, help is appreciated! Thanks!
You could check the current scene for the "_purchaseOnly" property and see if it's false.
JavaScript:
if (!SceneManager._scene._purchaseOnly) {
    // code
}
You can check SceneManager._scene._commandWindow.currentSymbol(): it'll either be "buy" or "sell".

You could check the current scene for the "_purchaseOnly" property and see if it's false.
JavaScript:
if (!SceneManager._scene._purchaseOnly) {
    // code
}

That won't quite work: in a shop that's *not* purchase only, that still wouldn't tell you whether you're buying or selling.
Scene_Shop doesn't directly pass that along to Window_ShopNumber. You'd either need to pass that info during the window handling process, or check back with the scene. This would be a quick and dirty way to check:

JavaScript:
Window_ShopNumber.prototype.isSellMode = function() {
    const scene = SceneManager._scene;
    return scene instanceof Scene_Shop && scene._commandWindow && scene._commandWindow.currentSymbol() === "sell";
};

Edit: too slow.
Dang, thanks for all the input, everyone!

@Kenen I chopped up the js you suggested, grabbing the const and checking the current symbol and got this, which works! Thank you!

Code:
if (scene._commandWindow.currentSymbol() === "sell") {
        this.drawText('Selling: ', x, y, width)
        this.drawItemName(this._item, this.textWidth('Selling: ') + 18, y, width);
    } else if (scene._commandWindow.currentSymbol() === "buy"){
        this.drawText('Purchase: ', x, y, width)
        this.drawItemName(this._item, this.textWidth('Purchase: ') + 18, y, width);
    };
I would personally leave the check inside a standalone method as I provided, and include the safety checks to ensure you're only providing yourself with valid information. You do you though.
I would personally leave the check inside a standalone method as I provided, and include the safety checks to ensure you're only providing yourself with valid information. You do you though.
Ok sounds good! I'll make that adjustment. Thanks!
This thread is closed due to being marked solved. Report the next one so we can find it! If you need this one reopened, report it to let us know. Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/solved-how-to-check-if-window_shopnumber-is-selling-mode-or-buying-mode.175392/