Disable "Up" and "Left" Map Movement

Discussion in 'JS Plugin Requests' started by mathmaster74, Jun 15, 2019.

  1. mathmaster74

    mathmaster74 just...John Veteran

    Messages:
    285
    Likes Received:
    184
    Location:
    Sheboygan, WI USA
    First Language:
    English
    Primarily Uses:
    RMMV
    Pretty much just what the title says. I need a short script snippet that forces the player to be unable to use left arrow and up arrow to control main character movement for...well...the duration of the game! :hhappy:
     
    #1
  2. caethyril

    caethyril ^_^ Veteran

    Messages:
    954
    Likes Received:
    592
    Location:
    UK
    First Language:
    English
    Primarily Uses:
    RMMV
    Try saving this as a .js file and importing as a plugin~
    Code:
    (function() {
    
    'use strict';
    
    	const FORBID = [4, 8];	// forbidden player movement directions
    
    	let alias = Game_Player.prototype.getInputDirection;
    	Game_Player.prototype.getInputDirection = function() {
    		let out = alias.call(this);
    		if (FORBID.contains(out)) return 0;
    		return out;
    	};
    
    })();
    I.e. "get input direction; if it's forbidden then return 0 (no move); else return direction". RMMV uses numpad directions; 4 = left and 8 = up. :)
     
    #2
    Silva and Hyouryuu-Na like this.
  3. ShadowDragon

    ShadowDragon Veteran Veteran

    Messages:
    400
    Likes Received:
    114
    Location:
    Netherlands
    First Language:
    Dutch
    Primarily Uses:
    RMMV
    or this plugin to disable others if need later if need.
     
    #3
    caethyril likes this.

Share This Page