Hello,
I am still struggling to understand how plugins work. I've got this one made up that is intended to enable/disable the script that turns an event towards the player when you interact with it.
Unfortunately, it isn't working, and I have no idea why.
My best guess was that I am not correctly grabbing the eventId, but even so, the commands don't show up in the Plugin Command list, so I'm sure I've screwed those up as well.
I've also tried writing script into an event to manually trigger _noTurn (this._noTurn = true), but that got me nowhere.
I'm also not confident that this is compatible with RMMZ, as I can only ever seem to find posts/advice about RMMV.
Thank you for your time.
I am still struggling to understand how plugins work. I've got this one made up that is intended to enable/disable the script that turns an event towards the player when you interact with it.
Unfortunately, it isn't working, and I have no idea why.
//=============================================================================
// NoTurnEvent.js
//=============================================================================
/*:
* @plugindesc Prevents events from turning when interacted with.
* @Author Connor
*
* @Help This plugin prevents events from turning when the player interacts with them.
*
*/
(function() {
// Alias the Game_Event.prototype.turnTowardPlayer function
const _Game_Event_turnTowardPlayer = Game_Event.prototype.turnTowardPlayer
Game_Event.prototype.turnTowardPlayer = function() {
// Check if the event is configured to not turn
if (!this._noTurn) {
// If not, proceed with normal turning behavior
_Game_Event_turnTowardPlayer.call(this);
}
};
// Create a plugin command to enable or disable turning for specific events
PluginManager.registerCommand('NoTurnEvent', 'EnableTurning', args => {
const eventId = parseInt(args.eventId);
const event = $gameMap.event(eventId);
if (event) {
event._noTurn = false;
}
});
PluginManager.registerCommand('NoTurnEvent', 'DisableTurning', args => {
const eventId = parseInt(args.eventId);
const event = $gameMap.event(eventId);
if (event) {
event._noTurn = true;
}
});
});
// NoTurnEvent.js
//=============================================================================
/*:
* @plugindesc Prevents events from turning when interacted with.
* @Author Connor
*
* @Help This plugin prevents events from turning when the player interacts with them.
*
*/
(function() {
// Alias the Game_Event.prototype.turnTowardPlayer function
const _Game_Event_turnTowardPlayer = Game_Event.prototype.turnTowardPlayer
Game_Event.prototype.turnTowardPlayer = function() {
// Check if the event is configured to not turn
if (!this._noTurn) {
// If not, proceed with normal turning behavior
_Game_Event_turnTowardPlayer.call(this);
}
};
// Create a plugin command to enable or disable turning for specific events
PluginManager.registerCommand('NoTurnEvent', 'EnableTurning', args => {
const eventId = parseInt(args.eventId);
const event = $gameMap.event(eventId);
if (event) {
event._noTurn = false;
}
});
PluginManager.registerCommand('NoTurnEvent', 'DisableTurning', args => {
const eventId = parseInt(args.eventId);
const event = $gameMap.event(eventId);
if (event) {
event._noTurn = true;
}
});
});
My best guess was that I am not correctly grabbing the eventId, but even so, the commands don't show up in the Plugin Command list, so I'm sure I've screwed those up as well.
I've also tried writing script into an event to manually trigger _noTurn (this._noTurn = true), but that got me nowhere.
I'm also not confident that this is compatible with RMMZ, as I can only ever seem to find posts/advice about RMMV.
Thank you for your time.