MV adding a dialogue window to scene_shop

hiii everyone

im making a plugin that adds a talk option to the shop scene. the code for the dialogue options is working just fine but now the sell and buy commands don't really work as intended? if you choose the buy opton and then cancel this happens:
Spoiler: screenshot
1751703596135.png

the weirder thing is that if you trigger the talk option first and then try to buy something everything is fine. Any ideas what's happening? Help greatly appreciated 🙂 Here's the plugin (pls don't judge too harshly for my bad formatting):

Spoiler: plugin
///-------------talk option in scene_shop-------------///
//adding the option to command window//
Scene_Shop.prototype.create = function() {
Scene_MenuBase.prototype.create.call(this);
this.createHelpWindow();
this.createGoldWindow();
this.createCommandWindow();
this.createTalkWindow();
this.createDummyWindow();
this.createNumberWindow();
this.createStatusWindow();
this.createBuyWindow();
this.createCategoryWindow();
this.createSellWindow();
};
Window_ShopCommand.prototype.maxCols = function() {
return 4;
};
Window_ShopCommand.prototype.makeCommandList = function() {
this.addCommand(TextManager.buy, 'buy');
this.addCommand(TextManager.sell, 'sell', !this._purchaseOnly);
this.addCommand("Talk", 'talk');
this.addCommand(TextManager.cancel, 'cancel');
};
Scene_Shop.prototype.createCommandWindow = function() {
this._commandWindow = new Window_ShopCommand(this._goldWindow.x, this._purchaseOnly);
this._commandWindow.y = this._helpWindow.height;
this._commandWindow.setHandler('buy', this.commandBuy.bind(this));
this._commandWindow.setHandler('sell', this.commandSell.bind(this));
this._commandWindow.setHandler('talk', this.commandTalk.bind(this));
this._commandWindow.setHandler('cancel', this.popScene.bind(this));
this.addWindow(this._commandWindow);
};
//talk command code//
//when pressed
Scene_Shop.prototype.commandTalk = function() {
this._dummyWindow.hide();
this.activateTalkWindow();
};
Scene_Shop.prototype.activateTalkWindow = function() {
this._talkWindow.show();
this._talkWindow.activate();
this._statusWindow.show();
};
//creating talk window
Scene_Shop.prototype.createTalkWindow = function() {
this._talkWindow = new Window_ShopTalk();
this._talkWindow.hide();
this._talkWindow.setHandler('option1', this.commandToTitle.bind(this));
this._talkWindow.setHandler('option2', this.commandToTitle.bind(this));
this._talkWindow.setHandler('cancel', this.onTalkCancel.bind(this));
this.addWindow(this._talkWindow);
};
//placeholder code for dialogue options
Scene_Shop.prototype.commandToTitle = function() {
this.fadeOutAll();
SceneManager.goto(Scene_Title);
};
//closing talk window
Scene_Shop.prototype.onTalkCancel = function() {
this._commandWindow.activate();
this._dummyWindow.show();
this._talkWindow.hide();
this._statusWindow.hide();
this._statusWindow.setItem(null);
this._helpWindow.clear();
};
//-----------------------------------------------------------------------------
// Window_ShopTalk
//
// The window for selecting an item to buy on the shop screen.
function Window_ShopTalk() {
this.initialize.apply(this, arguments);
}
Window_ShopTalk.prototype = Object.create(Window_Command.prototype);
Window_ShopTalk.prototype.constructor = Window_ShopTalk;
Window_ShopTalk.prototype.initialize = function() {
Window_Command.prototype.initialize.call(this, 0, 180);
};
Window_ShopTalk.prototype.windowWidth = function() {
return 456;
};
Window_ShopTalk.prototype.windowHeight = function() {
return 444;
};

//talk window options (placeholder)
Window_ShopTalk.prototype.makeCommandList = function() {
this.addCommand("Your wares", 'option1');
this.addCommand("About you", 'option2');
this.addCommand("Weather", 'option3');
this.addCommand("About the King", 'option4');
this.addCommand("Exit", 'cancel');
};
cancel didn't reactivate the buy/sell window, but not sure on the other
parts of option 1 being to scene title?

NPCDialogueShop does have a talk option including a bust.

you can credit her/him for using the code how he/she created it.
as it is bound to a common event and a variable to track down the talk
of the current shop.

or use that plugin to simplify it on your own.
I think you need to deactivate it when you create the talk window, like:

this._talkWindow.deactivate();
I think you need to deactivate it when you create the talk window, like:

this._talkWindow.deactivate();
this worked!!! thanks so much
cancel didn't reactivate the buy/sell window, but not sure on the other
parts of option 1 being to scene title?

NPCDialogueShop does have a talk option including a bust.

you can credit her/him for using the code how he/she created it.
as it is bound to a common event and a variable to track down the talk
of the current shop.

or use that plugin to simplify it on your own.
I know there are actually a few plugins out there that let you talk to shopkeepers, but I wanted to practice plugin-making and learn to add new windows to scenes. I checked out NPCDialogueShop - it's great! - but it's not exactly what I need. Thanks anyway! 🙂

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/adding-a-dialogue-window-to-scene_shop.178738/