[solve]Use only left and right walk animation problem with vertical sheet !etc.png

I had ask about this
https://forums.rpgmakerweb.com/inde...se-only-left-and-right-walk-animation.105648/
and @caethyril kindly help me to make this script

Code:
/*:
 * @plugindesc Ignores attempts to make characters face up or down.
 * @author Caethyril
 * @help Free to use and modify.
 */

(function() {

'use strict';

    let _Game_CharacterBase_setDirection = Game_CharacterBase.prototype.setDirection;
    Game_CharacterBase.prototype.setDirection = function(d) {
        if (![2,8].contains(d)) _Game_CharacterBase_setDirection.call(this, d);
    };

})();

// To affect only the player, replace all 4 "Game_CharacterBase" with "Game_Player"

basically everything work fine
untill I notice some odd about door and switch sprite
it's only use R/L by this script so that the problem with vertical animation sheet

the affect only player is not an option because I do action map battle game
the enemy[event] need to use only R/L same as player

thank you
You could add another check to determine doors and switches, like maybe check the event name, if it says door, then it should follow the normal directions then you just need to make sure your door events have door it their names.
Another option could be to filter out "object character" events, i.e. characters with spritesheets whose files start with !, like !Door.png. Here are a couple of examples:
  • By event name (case-sensitive):
    Code:
    	let _Game_CharacterBase_setDirection = Game_CharacterBase.prototype.setDirection;
    	Game_CharacterBase.prototype.setDirection = function(d) {
    		let allowText = 'Door';
    		if (![2,8].contains(d) || ((this instanceof Game_Event) && this.event().name.contains(allowText))) {
    			_Game_CharacterBase_setDirection.call(this, d);
    		}
    	};
  • By object character:
    Code:
    	let _Game_CharacterBase_setDirection = Game_CharacterBase.prototype.setDirection;
    	Game_CharacterBase.prototype.setDirection = function(d) {
    		if (![2,8].contains(d) || this.isObjectCharacter()) {
    			_Game_CharacterBase_setDirection.call(this, d);
    		}
    	};
thank you both of you
I'm tested and that work great

and for any one not understand code like me
more info
'door' is string name can change with any thing in ' '
like 'vertical'
and can paste in your event name with another text like

event001 vertical


or the second code
it will automatic check your sprite sheet that got ! in the name

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/solve-use-only-left-and-right-walk-animation-problem-with-vertical-sheet-etc-png.106198/