While I support the previous posts' recommendations of using some variables and checking them afterwards, if you want to be able to handle the rare edge case where it may not work due to buy/sell math balancing out, here is a plugin to do so:
Code:
/*:
* @plugindesc Sets a switch to ON if the party bought something in a shop,
* then to OFF whenever a new shop interaction starts.
* @author Zevia
*
* @help Specify the number of the switch to be reserved for confirming whether the
* party bought something in a shop.
* Whenever the shop Scene is initiated, the switch is set to OFF. If something
* is purchased, the switch is set to ON.
*
* @param switchNumber
* @text Confirm Buy Switch Number
* @type switch
* @desc The switch number to set ON if an item is purchased or
* OFF if not
* @default 15
*/
(function(module) {
'use strict';
var Zevia = module.Zevia || {};
var switchNumber = parseInt(PluginManager.parameters('ConfirmShopBuy').switchNumber);
if (isNaN(switchNumber)) {
throw new Error(
'Configuration Error: ConfirmShopBuy requires a valid switch number to be' +
' specified in the setup parameters'
);
}
Zevia.SceneShopCreate = Scene_Shop.prototype.create;
Scene_Shop.prototype.create = function() {
Zevia.SceneShopCreate.call(this);
$gameSwitches.setValue(switchNumber, false);
};
Zevia.SceneShopBuy = Scene_Shop.prototype.doBuy;
Scene_Shop.prototype.doBuy = function(number) {
Zevia.SceneShopBuy.call(this, number);
$gameSwitches.setValue(switchNumber, true);
}
})(window);
You'll want to copy it into a file called ConfirmShopBuy.js (or change the 'ConfirmShopBuy' in the Plugin to whatever you feel like naming it). Alternatively, you may
click here and save this link as a .js file.
In the setup, pick an unused switch in your game to use. Every time a new shop scene is started, the switch is set to OFF. If the party buys anything, the switch is set to ON until another shop scene is started. You can also manually set the switch OFF after doing whatever you want post-scene, if you prefer.
May have compatibility issues with Plugins that overwrite the
create and
doBuy methods of the Shop Scene. If placing this Plugin beneath other Plugins doesn't solve the problem, someone will need to write a compatibility fix.