=begin #=============================================================================== Title: Direction Fix Button Author: Hime Date: Jan 17, 2015 -------------------------------------------------------------------------------- ** Change log Jan 17, 2015 - Initial release -------------------------------------------------------------------------------- ** Terms of Use * Free to use in commercial and non-commercial projects * No real support. The script is provided as-is * Will do bug fixes, but no compatibility patches * Features may be requested but no guarantees, especially if it is non-trivial * Credits to Hime Works in your project * Preserve this header -------------------------------------------------------------------------------- ** Description This script allows you to assign a button that will fix the player's direction when the button is pressed. This is useful if you wish to allow players to lock their direction while moving, for example if you want to provide "strafe movement" by moving side to side. A switch is provided to enable or disable the button's direction fixing behavior. The switch must be turned on in order for the button to fix the player's direction. This may be useful when you are creating a cut-scene and you don't want player actions to affect it. -------------------------------------------------------------------------------- ** Installation In the script editor, place this script below Materials and above Main -------------------------------------------------------------------------------- ** Usage In the configuration, choose which button you wish to use to force direction fixing. By default it is button X, which is the "A" key on your keyboard. When this button is pressed, the player's direction will be fixed. If you are using the default input system and you are not sure which keys correspond to which buttons by default, you can check the keyboard settings when you playtest the game and press F1. The enable/disable switch is also available in the configuration. #=============================================================================== =end $imported = {} if $imported.nil? $imported[:TH_DirectionFixButton] = true #=============================================================================== # ** Configuration #=============================================================================== module TH module Direction_Fix_Button # Button to use to fix player direction. Button = :X # Switch to determine whether the direction fix button will do anything # when pressed. When the switch is ON, the button is enabled. When the # switch is off, the button is disabled. Switch = 9999 end end class Game_System def direction_fix_button_enabled? $game_switches[TH::Direction_Fix_Button::Switch] end end class Game_Player < Game_Character alias :th_direction_fix_button_direction_fix :direction_fix def direction_fix return true if $game_system.direction_fix_button_enabled? && Input.press?(TH::Direction_Fix_Button::Button) th_direction_fix_button_direction_fix end #----------------------------------------------------------------------------- # Overwrite. Couldn't figure out how to preserve original settings after # releasing direction fix button so I decided to just take this one out and # have it make a method call. #----------------------------------------------------------------------------- def set_direction(d) @direction = d if !direction_fix && d != 0 @stop_count = 0 end end