So in MZ there is the built-in plugin ButtonPicture.js. It's great but I lack functionality that would be quite nice and I am wondering how I can make it useable within scripts rather than the plugin commands.
The entire code in the ButtonPicture.js looks like this, it is rather short, so that is quite nice. But since I am quite new, I've spent about 30-40 minutes trying to figure out how this actually works does but I've had no luck...
Thanks for any help!
Best regards,
Bishiba
The entire code in the ButtonPicture.js looks like this, it is rather short, so that is quite nice. But since I am quite new, I've spent about 30-40 minutes trying to figure out how this actually works does but I've had no luck...
JavaScript:
(() => {
const pluginName = "ButtonPicture";
PluginManager.registerCommand(pluginName, "set", args => {
const pictureId = Number(args.pictureId);
const commonEventId = Number(args.commonEventId);
const picture = $gameScreen.picture(pictureId);
if (picture) {
picture.mzkp_commonEventId = commonEventId;
}
});
Sprite_Picture.prototype.isClickEnabled = function() {
const picture = this.picture();
return picture && picture.mzkp_commonEventId && !$gameMessage.isBusy();
};
Sprite_Picture.prototype.onClick = function() {
$gameTemp.reserveCommonEvent(this.picture().mzkp_commonEventId);
};
Spriteset_Base.prototype.mzkp_isAnyPicturePressed = function() {
return this._pictureContainer.children.some(sprite =>
sprite.isPressed()
);
};
const _Scene_Map_isAnyButtonPressed =
Scene_Map.prototype.isAnyButtonPressed;
Scene_Map.prototype.isAnyButtonPressed = function() {
return (
_Scene_Map_isAnyButtonPressed.apply(this, arguments) ||
this._spriteset.mzkp_isAnyPicturePressed()
);
};
})();
Thanks for any help!
Best regards,
Bishiba