this is the part that handles the shop when it opens. I want the shop to be buy only, but I can figure out how to remove the sell command. Can someone please help?
JavaScript:
// Overriding the prepare method to accept custom items
var _Scene_Shop_prepare = Scene_Shop.prototype.prepare;
Scene_Shop.prototype.prepare = function (goods, purchaseOnly) {
_Scene_Shop_prepare.call(this, goods, purchaseOnly);
this._goods = goods;
this._purchaseOnly = purchaseOnly;
};
// Overriding the createCommandWindow method to customize command window
var _Scene_Shop_createCommandWindow = Scene_Shop.prototype.createCommandWindow;
Scene_Shop.prototype.createCommandWindow = function () {
_Scene_Shop_createCommandWindow.call(this);
if (this._purchaseOnly) {
this._commandWindow.setHandler('buy', this.commandBuy.bind(this));
this._commandWindow.setHandler('cancel', this.popScene.bind(this));
this._commandWindow.deactivate();
this._commandWindow.select(0);
}
};
// Overriding the commandSell method to disable selling if purchaseOnly is true
var _Scene_Shop_commandSell = Scene_Shop.prototype.commandSell;
Scene_Shop.prototype.commandSell = function () {
if (this._purchaseOnly) {
this.onSellCancel();
} else {
_Scene_Shop_commandSell.call(this);
}
};
// Method to handle cancellation of sell command
Scene_Shop.prototype.onSellCancel = function () {
SoundManager.playCancel();
this.popScene();
};
// Overriding makeItemList to use custom shop items
var _Window_ShopBuy_makeItemList = Window_ShopBuy.prototype.makeItemList;
Window_ShopBuy.prototype.makeItemList = function () {
this._data = [];
this._price = [];
if (this._shopGoods && this._shopGoods.length > 0) {
this._shopGoods.forEach(function (good) {
let item = null;
switch (good[0]) {
case 0: // Item
item = $dataItems[good[1]];
break;
case 1: // Weapon
item = $dataWeapons[good[1]];
break;
case 2: // Armor
item = $dataArmors[good[1]];
break;
}
if (item) {
this._data.push(item);
this._price.push(good[2] === 0 ? item.price : good[3]);
}
}, this);
}
_Window_ShopBuy_makeItemList.call(this);
};