SephirothSpawn
Sponsor
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
--------------------------------------------
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.
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.
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.
Now, down in this windows update method, we'll add a single line, and presto.
Our final product:
Simple enough. The same can be done for most HUDs, Sprite Objects, etc. Anything that has a visible method can be toggled with this.
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.