Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Turning an 8 directions script on and off through a switch?

I have Near's 8 way movement script, but there is a part in my game where I do not wish to move in 8 directions. Is it possible to have this work only if a certain switch is turned off? Here is the script:
Code:
#============================================================================
# VX Near Game_Player Edit Final Version
#----------------------------------------------------------------------------
#     Provides 8 Directional Movement to the Default Movement System.
#============================================================================
class Game_Player
  def move_by_input
    return unless movable?
    return if $game_map.interpreter.running?
    case Input.dir8
    when 1;  move_lower_left
    when 2;  move_down
    when 3;  move_lower_right
    when 4;  move_left
    when 6;  move_right
    when 7;  move_upper_left
    when 8;  move_up
    when 9;  move_upper_right
    end
  end
end
Thanks in advance! :smile:
  -KRoP
 
Here you go:
Code:
#============================================================================
# VX Near Game_Player Edit Final Version
#----------------------------------------------------------------------------
#     Provides 8 Directional Movement to the Default Movement System.
#============================================================================
class Game_Player
  def move_by_input
    return unless movable?
    return if $game_map.interpreter.running?
    if $game_switches[1]
      case Input.dir8
      when 1;  move_lower_left
      when 2;  move_down
      when 3;  move_lower_right
      when 4;  move_left
      when 6;  move_right
      when 7;  move_upper_left
      when 8;  move_up
      when 9;  move_upper_right
      end
    else
      case Input.dir4
      when 2;  move_down
      when 4;  move_left
      when 6;  move_right
      when 8;  move_up
      end
    end
  end
end

Replace your old script with this one. And replace the number in $game_switches[1] with the id of the switch that you wish to have to turn ON/OFF the 8-directional movement.

Over and out - Gando
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top