[RESOLVED] How to disable/enable an entire script?

Started by happyman, January 30, 2013, 03:06:41 am

Previous topic - Next topic

happyman

January 30, 2013, 03:06:41 am Last Edit: February 01, 2013, 03:43:28 am by happyman
Hello! I'm using a very cool Zelda Screen Transitions script in my game. It's a script that breaks apart a big map into smaller segments and has a smooth scrolling animation between the segments, just like the original Zelda game.

Problem is my game has a world map too, and I don't want the world map to use this script, only the inner areas like caves and such.

So what can I do to turn off and on an entire script? My knowledge of scripts is pretty limited, but I can do small mods to a simple script. I've tried searching for a solution, but maybe I don't know what to look for... Thanks in advance!

Here's the script in case anyone wants to take a peek:

#==============================================================================
# ** Classic Zelda Screen Transitions
#------------------------------------------------------------------------------
# * Created by: albertfish
# * Version: 1.0
# * Last edited: September 7, 2010
#------------------------------------------------------------------------------
#  Version History:
#    Version 1.0: September 7, 2010
#      - Initial release
#------------------------------------------------------------------------------
#  Description:
#    This script mimics the screen transitions found in the 2D Zelda Games.
#------------------------------------------------------------------------------
#  Features:
#    - Separeated a large map in to small screen size parts and adds a smooth
#      transition between the parts.
#------------------------------------------------------------------------------
#  Install Instructions:
#    Place this script above the main script and below the default scripts.
#==============================================================================

#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
#  This class brings together map screen sprites, tilemaps, etc.
#  It's used within the Scene_Map class.
#==============================================================================

class Spriteset_Map
 #--------------------------------------------------------------------------
 # * Object Initialization
 #--------------------------------------------------------------------------
 alias af_czst_ssm_init initialize
 def initialize
   @x = ($game_player.x - $game_player.x % 20) * 128
   @y = ($game_player.y - $game_player.y % 15) * 128
   @amount_x = 0
   @amount_y = 0
   @scrolling = false
   @prev_x = $game_player.x
   @prev_y = $game_player.y
   $game_map.display_x = @x
   $game_map.display_y = @y
   af_czst_ssm_init
 end
 #--------------------------------------------------------------------------
 # * Scroll Right
 #--------------------------------------------------------------------------
 def scroll_right
   @x += 128
   @amount_x -= 1
   if @amount_x <= 0
     @scrolling = false
   end
 end
 #--------------------------------------------------------------------------
 # * Scroll Left
 #--------------------------------------------------------------------------
 def scroll_left
   @x -= 128
   @amount_x += 1
   if @amount_x >= 0
     @scrolling = false
   end
 end
 #--------------------------------------------------------------------------
 # * Scroll Up
 #--------------------------------------------------------------------------
 def scroll_up
   @y -= 96
   @amount_y -= 1
   if @amount_y <= 0
     @scrolling = false
   end
 end
 #--------------------------------------------------------------------------
 # * Scroll Down
 #--------------------------------------------------------------------------
 def scroll_down
   @y += 96
   @amount_y += 1
   if @amount_y >= 0
     @scrolling = false
   end
 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 alias af_czst_ssm_update update
 def update
   if !@scrolling
     # Determine if the screen needs to scroll left or right
     if $game_player.x % 20 == 0 && ($game_player.x - 19) * 128 > $game_map.display_x
       @amount_x = 20
       @scrolling = true
       @prev_x += 1
     elsif $game_player.x % 20 == 19 && ($game_player.x) * 128 < $game_map.display_x
       @amount_x = -20
       @scrolling = true
       @prev_x -= 1
     end
     # Determine if the screen needs to scroll up or down
     if $game_player.y % 15 == 0 && ($game_player.y - 14) * 128 > $game_map.display_y
       @amount_y = -20
       @scrolling = true
       @prev_y += 1
     elsif $game_player.y % 15 == 14 && ($game_player.y) * 128 < $game_map.display_y
       @amount_y = 20
       @scrolling = true
       @prev_y -= 1
     end
   else @scrolling
     # Scroll either left or right
     if @amount_x > 0
       scroll_right
     elsif @amount_x < 0
       scroll_left
     end
     # Scroll either up or down
     if @amount_y < 0
       scroll_down
     elsif @amount_y > 0
       scroll_up
     end
     $game_player.x = @prev_x
     $game_player.y = @prev_y
   end
   $game_map.display_x = @x
   $game_map.display_y = @y
   @prev_x = $game_player.x
   @prev_y = $game_player.y
   af_czst_ssm_update
 end
end
class Game_Character
 def x=(x)
   @x = x
 end
 def y=(y)
   @y = y
 end
end

Blizzard

Please use code tags.
Also, the script seems to be incompletely pasted.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

happyman

January 30, 2013, 03:14:03 am #2 Last Edit: January 30, 2013, 03:16:09 am by happyman
Fixed script and added code tags instead. Sorry!

EDIT: Also, that was a super fast reply. You don't mess around!

Blizzard

Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

happyman

Any ideas? If there's a way to make the script work only while a certain switch is on, that's pretty much all I need. Or like in your ATES script I also use, I can toggle it with ATES.on and ATES.off using script commands. I like that a lot, but what do you think is easier?

Blizzard

In order to be able to turn a script on/off, the script has to be coded in such a way. And this means that this script would have to be edited.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

LiTTleDRAgo

#==============================================================================
# ** Classic Zelda Screen Transitions
#------------------------------------------------------------------------------
# * Created by: albertfish
# * Version: 1.0
# * Last edited: September 7, 2010
#------------------------------------------------------------------------------
#  Version History:
#    Version 1.0: September 7, 2010
#      - Initial release
#------------------------------------------------------------------------------
#  Description:
#    This script mimics the screen transitions found in the 2D Zelda Games.
#------------------------------------------------------------------------------
#  Features:
#    - Separeated a large map in to small screen size parts and adds a smooth
#      transition between the parts.
#------------------------------------------------------------------------------
#  Install Instructions:
#    Place this script above the main script and below the default scripts.
#==============================================================================

#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
#  This class brings together map screen sprites, tilemaps, etc.
#  It's used within the Scene_Map class.
#==============================================================================

class Spriteset_Map
  #--------------------------------------------------------------------------
  # * Constant Variable
  #--------------------------------------------------------------------------
  DISABLE_ZELDA_TRANSITION_SWITCH = 1
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias_method :af_czst_ssm_init,   :initialize
  alias_method :af_czst_ssm_update, :update
  define_method(:initialize){[scroll_zelda_transition(0),af_czst_ssm_init]}
  define_method(:update)    {[scroll_zelda_transition(1),af_czst_ssm_update]}
  #--------------------------------------------------------------------------
  # * Scroll Zelda Transition
  #--------------------------------------------------------------------------
  def scroll_zelda_transition(type=0)
    return if $game_switches[DISABLE_ZELDA_TRANSITION_SWITCH]
    if type == 0
      @x = ($game_player.x - $game_player.x % 20) * 128
      @y = ($game_player.y - $game_player.y % 15) * 128
      @amount_x = 0
      @amount_y = 0
      @scrolling = false
      @prev_x = $game_player.x
      @prev_y = $game_player.y
      $game_map.display_x = @x
      $game_map.display_y = @y
      return
    end
    if !@scrolling
      # Determine if the screen needs to scroll left or right
      if $game_player.x % 20 == 0 &&
          ($game_player.x - 19) * 128 > $game_map.display_x
        @amount_x = 20
        @scrolling = true
        @prev_x += 1
      elsif $game_player.x % 20 == 19 &&
          ($game_player.x) * 128 < $game_map.display_x
        @amount_x = -20
        @scrolling = true
        @prev_x -= 1
      end
      # Determine if the screen needs to scroll up or down
      if $game_player.y % 15 == 0 &&
          ($game_player.y - 14) * 128 > $game_map.display_y
        @amount_y = -20
        @scrolling = true
        @prev_y += 1
      elsif $game_player.y % 15 == 14 &&
          ($game_player.y) * 128 < $game_map.display_y
        @amount_y = 20
        @scrolling = true
        @prev_y -= 1
      end
    else @scrolling
      # Scroll either left or right
      if @amount_x > 0
        @x += 128
        @amount_x -= 1
        @scrolling = false if @amount_x <= 0
      elsif @amount_x < 0
        @x -= 128
        @amount_x += 1
        @scrolling = false if @amount_x >= 0
      end
      # Scroll either up or down
      if @amount_y < 0
        @y += 96
        @amount_y += 1
        @scrolling = false if @amount_y >= 0
      elsif @amount_y > 0
        @y -= 96
        @amount_y -= 1
        @scrolling = false if @amount_y <= 0
      end
      $game_player.class.send(:attr_accessor, :x,:y)
      $game_player.x = @prev_x
      $game_player.y = @prev_y
    end
    $game_map.display_x = @x
    $game_map.display_y = @y
    @prev_x = $game_player.x
    @prev_y = $game_player.y
  end
end


to disable it, enable switch 1

happyman

It works perfectly! You guys are amazing  :D