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.

Removing/Disabling Scripts Temporarily (Tutorial & Request Shop)

Removing/Disabling Scripts Temporarily
By SephirothSpawn

Introduction
Many people continue to ask, "How do I disable Script X during Y?" The simple answer is, there is no simple answer. Many scripts are complicated to the point where there is no simple way to disable a script. If you are showing a HUD or other visual effect, you just need to toggle the visibility. Other aspects require you to do a little more.

So what I am going to do is take a look at a few random types of scripts in the Script submission, show you how to make it able to be disabled with a simple game switch, and then allow you to try to figure out how to disable your scripts, and if you run into difficulties, request me to help you here. So lets begin:

HUDs

Simple HUD 1
HUD (Heads-Up-Display) are systems found in many games and there are several scripts that emulate this for RMXP/VX. So lets take a look at one.

Here is a quick HUD system I made for the purposes of this tutorial.
Code:
#==============================================================================
# ** Window_BasicHUD (By SephirothSpawn)
#------------------------------------------------------------------------------
#  A Simple HUD System shows a HUD on the map, that shows the current actor's
#  HP and SP.
#==============================================================================

#==============================================================================
# ** Window_BasicHUD
#==============================================================================

class Window_BasicHUD < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 224, 96)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 160
    update
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    draw_actor_hp(@actor, 0,  0, 192)
    draw_actor_sp(@actor, 0, 32, 192)
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    if @actor != $game_party.actors[0] || @hp != $game_party.actors[0].hp ||
       @sp != $game_party.actors[0].sp
      @actor = $game_party.actors[0]
      @hp = @actor.hp
      @sp = @actor.sp
      refresh
    end
  end
end

#==============================================================================
# ** Scene_Map
#==============================================================================

class Scene_Map
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias_method :seph_basichud_scnmap_main, :main
  alias_method :seph_basichud_scnmap_updt, :update
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Create HUD
    @hud_window = Window_BasicHUD.new
    # Original Main
    seph_basichud_scnmap_main
    # Dispose HUD
    @hud_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update HUD
    @hud_window.update
    # Original Update
    seph_basichud_scnmap_updt
  end
end

Now, this HUD creates a window on the map showing the main actor's hp and sp. But as of now, it always shows. What if we wanted to disable it if a switch is on. All we have to do is update its visibility if a switch is on. Doesn't get any simpler. Let's create a constant that lets you choose which switch that must be on for it to be visible.

Code:
#==============================================================================
# ** Window_BasicHUD
#==============================================================================

class Window_BasicHUD < Window_Base
  #--------------------------------------------------------------------------
  # * Visible Switch
  #--------------------------------------------------------------------------
  Visible_Switch = 1

Now, down in this windows update method, we'll add a single line, and presto.
Code:
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    self.visible = $game_switches[Visible_Switch]

Our final product:
Code:
#==============================================================================
# ** Window_BasicHUD (By SephirothSpawn)
#------------------------------------------------------------------------------
#  A Simple HUD System shows a HUD on the map, that shows the current actor's
#  HP and SP.
#==============================================================================

#==============================================================================
# ** Window_BasicHUD
#==============================================================================

class Window_BasicHUD < Window_Base
  #--------------------------------------------------------------------------
  # * Visible Switch
  #--------------------------------------------------------------------------
  Visible_Switch = 1
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 224, 96)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 160
    update
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    draw_actor_hp(@actor, 0,  0, 192)
    draw_actor_sp(@actor, 0, 32, 192)
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    self.visible = $game_switches[Visible_Switch]
    if @actor != $game_party.actors[0] || @hp != $game_party.actors[0].hp ||
       @sp != $game_party.actors[0].sp
      @actor = $game_party.actors[0]
      @hp = @actor.hp
      @sp = @actor.sp
      refresh
    end
  end
end

#==============================================================================
# ** Scene_Map
#==============================================================================

class Scene_Map
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias_method :seph_basichud_scnmap_main, :main
  alias_method :seph_basichud_scnmap_updt, :update
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Create HUD
    @hud_window = Window_BasicHUD.new
    # Original Main
    seph_basichud_scnmap_main
    # Dispose HUD
    @hud_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update HUD
    @hud_window.update
    # Original Update
    seph_basichud_scnmap_updt
  end
end

Simple enough. The same can be done for most HUDs, Sprite Objects, etc. Anything that has a visible method can be toggled with this.


--------------------------------------------

I have a few more in mind, but it's Friday night. I figured if I started this, I would keep on it. If you have any scripts that you want to know how to toggle on and off, post 'em here. I want a bunch of different types of scripts to show how to do it.
 
It may take a while. I haven't even started them yet because I am very becked up. I am going to have a look at the XAS battle system tonight and take a look at it.
 
Actually, Kain Nobel already helped resolve this for me here. Unfortunately his "Pastebin" file with the code in it expired. I can post the code and some instructions, though, if you don't mind.
 
Okay. Since I've already configured many lines in the XAS, copy-pasting probably won't work out for some of you, so I'll just provide instructions.

1. In the XRXS-XAS script, search for "module XAS_COMMAND" (it should be near the very beginning of the script, use Ctrl-F if you're having trouble). Under that line, insert "DISABLE = false".

2. Find the line,
Code:
if Input.trigger?(XAS_COMMAND::SKILL_ACTION)
and replace it with
Code:
if Input.trigger?(XAS_COMMAND::SKILL_ACTION) and not XAS_COMMAND::DISABLE

3. A few lines down, replace
Code:
if Input.trigger?(XAS_COMMAND::SLASH_ACTION)
with
Code:
if Input.trigger?(XAS_COMMAND::SLASH_ACTION) and not XAS_COMMAND::DISABLE

4. Do the same with
Code:
if Input.trigger?(XAS_COMMAND::SHIELD_ACTION)
and
Code:
if Input.trigger?(XAS_COMMAND::ITEM_ACTION)

by adding " and not XAS_COMMAND::DISABLE" at the end of each line.

5. Now whenever you want to disable/enable the commands in an event, simply use a "Call Script" and type "XAS_COMMAND::DISABLE = true/nil".

Note that this does not cancel the entire battle system, only the attack, shield, skill, and item commands. Enemies can still attack you on the field. If you want to fully disable the script, further editing is needed. You'll have to ask SephirothSpawn if you want that.

Credit goes to Kain Nobel for the edit.
 

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