Invert controls

I simply would be able to invert the player's movement controls at a certain point, maybe based on a switch or map id.
Any solutions?
The truth is I don't know if it is the most appropriate method: try an event in autorun that checks if, for example, pressing the left button and the event moves you to the right. Otherwise you will need a script ...which I think does not exist for this.

This would be done by a common event that a switch will request either in autorun or in parallel process, if you want it to occur in a special map, configure a variable based on it, although this does not make much sense if the switch method is chosen.
The truth is I don't know if it is the most appropriate method: try an event in autorun that checks if, for example, pressing the left button and the event moves you to the right. Otherwise you will need a script ...which I think does not exist for this.
I tried with common events, and it just doesn't work well. For example, if i press up the pg first moves up and then down, sometimes it stucks in a cycle or freeze the game becouse of collisions.

I think this is a pretty common feature in rpgs, i's possible that someone has done sonething about it...at least i hope.
I tried with common events, and it just doesn't work well. For example, if i press up the pg first moves up and then down, sometimes it stuck
It's in autorun, I just did it and it worked for me, did you select "skip if can't move" in the move route?.
You can do it using events, but it needs to create a condition for stopping too, so it prevents the character from moving in the right direction.

Logical:
Code:
@>Conditional Branch: Button Down is Being Pressed
   @>Set Move Route: Player (Skip)
   :                      : $>Move Up
   @>
: Else
    @>Conditional Branch: Button Up is Being Pressed
       @>Set Move Route: Player (Skip)
       :                      : $>Move Down
       @>
    : Else
        @>Conditional Branch: Button Left is Being Pressed
           @>Set Move Route: Player (Skip)
           :                      : $>Move Right
           @>
        : Else
            @>Conditional Branch: Button Right is Being Pressed
               @>Set Move Route: Player (Skip)
               :                      : $>Move Left
               @>
            : Else
               @>Set Move Route: Player (Skip)
               :                      : $>Wait: 1 frames(s)
               @>
            :  Branch End
            @>
        :   Branch End
        @>
    :   Branch End
    @>
:   Branch End
@>

I'm out of my computer at the moment, so I may have written something wrong.
You have to create each "IF" within the "Else" of the previous one, because it will also be necessary to create a condition for collision with other events, if not dialogues with NPCs or things like that will not work.

Edit:
I don't particularly like using the "Shift" key to accelerate, but if necessary, you will have to create a condition for this key with each move.

If it's a little complicated, I create a demo.
Here's a script for that, modify the switch number in the module, and use that switch on true to invert and false for normal movement.

Ruby:
module ZERO
  # Set switch number to track the inverted movement status
  INVERTED_SWITCH = 100
end

class Game_Player < Game_Character
  alias zero_move_straight move_straight
  def move_straight(d, turn_ok = true)
    if $game_switches[ZERO::INVERTED_SWITCH]
      case d
        when 4
          d = 6
        when 6
          d = 4
        when 8
          d = 2
        when 2
          d = 8
      end
    end
    zero_move_straight(d, turn_ok)
  end
end
Here's a script for that, modify the switch number in the module, and use that switch on true to invert and false for normal movement.

Ruby:
module ZERO
  # Set switch number to track the inverted movement status
  INVERTED_SWITCH = 100
end

class Game_Player < Game_Character
  alias zero_move_straight move_straight
  def move_straight(d, turn_ok = true)
    if $game_switches[ZERO::INVERTED_SWITCH]
      case d
        when 4
          d = 6
        when 6
          d = 4
        when 8
          d = 2
        when 2
          d = 8
      end
    end
    zero_move_straight(d, turn_ok)
  end
end
It perfectly works! Thank you very much!

The only issue is that i use this script that adds the 8 directions movement, but i can perfectly toggle it off for this section of the game if it's hard to fix.
Here's an updated script, put it after 8-dir script
Ruby:
module ZERO
    # Set switch number to track the inverted movement status
    INVERTED_SWITCH = 100
end
  
class Game_Player < Game_Character
  
  # Alias move_straight
  alias zero_move_straight move_straight
  def move_straight(d, turn_ok = true)
    if $game_switches[ZERO::INVERTED_SWITCH] == true
      case d
        when 4
          d = 6
        when 6
          d = 4
        when 8
          d = 2
        when 2
          d = 8
      end
    end
    zero_move_straight(d, turn_ok)
  end

  # New function
  # Support for 8 Dir Move by JVScripts
  def case_diagonal
    case Input.dir8
      when 2, 4, 6, 8
          move_straight(Input.dir4)
      when 1
          $game_switches[ZERO::INVERTED_SWITCH] ? move_diagonal(6, 8) : move_diagonal(4, 2)
      when 3
          $game_switches[ZERO::INVERTED_SWITCH] ? move_diagonal(4, 8) : move_diagonal(6, 2)
      when 7
          $game_switches[ZERO::INVERTED_SWITCH] ? move_diagonal(6, 2) : move_diagonal(4, 8)
      when 9
          $game_switches[ZERO::INVERTED_SWITCH] ? move_diagonal(4, 2) : move_diagonal(6, 8)
    end
  end
    
  # Overwrite move_by_input
  # Support for 8 Dir Move by JVScripts
  # Only overwrite if 8 Dir Move script is loaded
  if JvScripts.const_defined?(:Dirs8)
    def move_by_input
      return if !movable? || $game_map.interpreter.running?
      if JvScripts::Dirs8::Switch > 0
        if $game_switches[JvScripts::Dirs8::Switch] == true
          case_diagonal
        else
          move_straight(Input.dir4) if Input.dir4 > 0
        end
      else
        case_diagonal if Input.dir8 > 0
      end
    end
  end
end
Here's an updated script, put it after 8-dir script
Ruby:
module ZERO
    # Set switch number to track the inverted movement status
    INVERTED_SWITCH = 100
end
 
class Game_Player < Game_Character
 
  # Alias move_straight
  alias zero_move_straight move_straight
  def move_straight(d, turn_ok = true)
    if $game_switches[ZERO::INVERTED_SWITCH] == true
      case d
        when 4
          d = 6
        when 6
          d = 4
        when 8
          d = 2
        when 2
          d = 8
      end
    end
    zero_move_straight(d, turn_ok)
  end

  # New function
  # Support for 8 Dir Move by JVScripts
  def case_diagonal
    case Input.dir8
      when 2, 4, 6, 8
          move_straight(Input.dir4)
      when 1
          $game_switches[ZERO::INVERTED_SWITCH] ? move_diagonal(6, 8) : move_diagonal(4, 2)
      when 3
          $game_switches[ZERO::INVERTED_SWITCH] ? move_diagonal(4, 8) : move_diagonal(6, 2)
      when 7
          $game_switches[ZERO::INVERTED_SWITCH] ? move_diagonal(6, 2) : move_diagonal(4, 8)
      when 9
          $game_switches[ZERO::INVERTED_SWITCH] ? move_diagonal(4, 2) : move_diagonal(6, 8)
    end
  end
   
  # Overwrite move_by_input
  # Support for 8 Dir Move by JVScripts
  # Only overwrite if 8 Dir Move script is loaded
  if JvScripts.const_defined?(:Dirs8)
    def move_by_input
      return if !movable? || $game_map.interpreter.running?
      if JvScripts::Dirs8::Switch > 0
        if $game_switches[JvScripts::Dirs8::Switch] == true
          case_diagonal
        else
          move_straight(Input.dir4) if Input.dir4 > 0
        end
      else
        case_diagonal if Input.dir8 > 0
      end
    end
  end
end
Thanks so much!
The easiest way to calculate the opposite direction is the following:
10 - current direction
Moved to: RGSS3 Script Requests

Original thread: https://forums.rpgmakerweb.com/threads/invert-controls.136047/