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.

[VX] Turning scripts on and off

J4iru5

Member

I'm using Near's Simple 8 way movement system and was wondering if it can be turned on and off with a switch, preferably this script is only enabled in certain maps.
So the 8 way movement is only enabled in map 001-007 either using scripting, or an event that will also turn off the 8 way movement when outside the map.

For reference to Near's Simple 8 Direction movement system;
http://www.rmxp.org/forums/index.php?topic=43896.0

Gladly welcome any help, cuz i'd really love it.
 

poccil

Sponsor

There are two ways to proceed here: use a switch, or limit the use to certain maps.  The procedure shown here is deliberately generic, since it can apply to many situations.

First, here's a way to wrap code so it will work only if a switch is on (in this case, switch 15):

Code:
# If switch 15 is on
if $game_switches[15]
  # Code to activate/deactivate goes here
end
Switches can be accessed in a script using $game_switches 
 

J4iru5

Member

Thanks for the help, but i'm still kinda confused. In the case of Near's movement script, where do i place it in the script if i'm using code where it only works in maps 7-18, and what would be the code to activate/deactivate be?
 

poccil

Sponsor

This is the modification to make to that script.

Code:
class Game_Player
  def move_by_input
    return unless movable?
    return if $game_map.interpreter.running?
    #If map is ID 7 through 18
    if $game_map.map_id>=7 || $game_map.map_id<=18
      input=Input.dir8
    else # Otherwise
      input=Input.dir4
    end
    case input
      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
 

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