This here is the code for a plugin I'm trying to make to allow a common event, Variable Id and a variable value to run when a mouse is hovering over a picture. It's similar to the ButtonPicture.js plugin that came with RPG Maker MZ. When I run the code I don't get any errors but it doesn't seem to be working either and I was hoping I could get some help as I am new to coding and making plugins for RPG Maker MZ. I will also make this plugin available for FREE after it is done and working.
(() => {
const pluginName = "HoverPicture";
PluginManager.registerCommand(pluginName, "set", args => {
const pictureId = Number(args.pictureId);
const commonEventId = Number(args.commonEventId);
const variableId = Number(args.VariableId);
const variableValue = args.VariableValue;
const picture = $gameScreen.picture(pictureId);
if (picture) {
picture.mzkp_commonEventId = commonEventId;
picture.mzkp_variableId = variableId;
picture.mzkp_variableValue = variableValue;}
});
Sprite_Picture.prototype.isHoveredEnabled = function() {
const picture = this.picture();
return picture && picture.mzkp_commonEventId && picture.mzkp_variableId && picture.mzkp_variableValue && !$gameMessage.isBusy();
};
Sprite_Picture.prototype.onHover = function() {
const picture = this.picture();
if (picture && picture.mzkp_commonEventId && picture.mzkp_variableId && picture.mzkp_variableValue) {
$gameTemp.reserveCommonEvent(picture.mzkp_commonEventId);
$gameVariables.setValue(picture.mzkp_variableId, picture.mzkp_variableValue);
}
};
Spriteset_Base.prototype.mzkp_isAnyPictureHovered = function() {
return this._pictureContainer.children.some(sprite =>
sprite.isHovered()
);
};
const _Scene_Map_isAnyButtonHovered =
Scene_Map.prototype._Scene_Map_isAnyButtonHovered;
Scene_Map.prototype._Scene_Map_isAnyButtonHovered = function() {
return (
_Scene_Map_isAnyButtonHovered.apply(this, arguments) ||
this._spriteset.mzkp_isAnyPictureHovered()
);
};
})();
Thank you for your time and thanks in advance for any help.
(() => {
const pluginName = "HoverPicture";
PluginManager.registerCommand(pluginName, "set", args => {
const pictureId = Number(args.pictureId);
const commonEventId = Number(args.commonEventId);
const variableId = Number(args.VariableId);
const variableValue = args.VariableValue;
const picture = $gameScreen.picture(pictureId);
if (picture) {
picture.mzkp_commonEventId = commonEventId;
picture.mzkp_variableId = variableId;
picture.mzkp_variableValue = variableValue;}
});
Sprite_Picture.prototype.isHoveredEnabled = function() {
const picture = this.picture();
return picture && picture.mzkp_commonEventId && picture.mzkp_variableId && picture.mzkp_variableValue && !$gameMessage.isBusy();
};
Sprite_Picture.prototype.onHover = function() {
const picture = this.picture();
if (picture && picture.mzkp_commonEventId && picture.mzkp_variableId && picture.mzkp_variableValue) {
$gameTemp.reserveCommonEvent(picture.mzkp_commonEventId);
$gameVariables.setValue(picture.mzkp_variableId, picture.mzkp_variableValue);
}
};
Spriteset_Base.prototype.mzkp_isAnyPictureHovered = function() {
return this._pictureContainer.children.some(sprite =>
sprite.isHovered()
);
};
const _Scene_Map_isAnyButtonHovered =
Scene_Map.prototype._Scene_Map_isAnyButtonHovered;
Scene_Map.prototype._Scene_Map_isAnyButtonHovered = function() {
return (
_Scene_Map_isAnyButtonHovered.apply(this, arguments) ||
this._spriteset.mzkp_isAnyPictureHovered()
);
};
})();
Thank you for your time and thanks in advance for any help.