Enable a switch while running?

In RPG Maker VX Ace, how do i activate switch when dashing/running?
try this in a new script slot (change 5 to whatever switch you want to be turned on/off):

Code:
class Game_Player < Game_Character
  alias :dash_update :update
  def update
    $game_switches[5] = dash? && moving?
    dash_update
  end
end

this will turn on the switch if you're moving AND dashing. If you're not moving, it will return false, even if you're holding the button down.

If you want it to return true when you're holding down the button, even if you're not moving, just remove the && moving? at the end of that line.

Original thread: https://forums.rpgmakerweb.com/threads/enable-a-switch-while-running.94629/