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:
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):
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:
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):
///-------------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');
};
//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');
};