Chaos Project

RPG Maker => RPG Maker Scripts => RMXP Script Database => Topic started by: Valdred on April 16, 2010, 09:54:28 am

Title: [XP] Extended debug
Post by: Valdred on April 16, 2010, 09:54:28 am
Extended debug
Authors: Valdred
Version: 1.0
Type: More powerful debug
Key Term: Game Utility



Introduction
Just a really simple script to make debugging more powerful. No credit needed if used.


Features




Screenshots
Spoiler: ShowHide
(http://bb.xieke.com/files/7/Uten%20navn.bmp)




Script
Spoiler: ShowHide

#==============================================================================
# ** Extended debug
#------------------------------------------------------------------------------
#  This script extends the scene debug.
#------------------------------------------------------------------------------
#  *by Valdred
#  *Contact me at: Chaos-project.com, rmvxp.com or valdred.com
#==============================================================================

class Window_Gold < Window_Base
 #--------------------------------------------------------------------------
 # * Object Initialization
 #--------------------------------------------------------------------------
 def initialize
   super(0, 0, 160, 64)
   self.contents = Bitmap.new(width - 32, height - 32)
   refresh
 end
 #--------------------------------------------------------------------------
 # * Refresh
 #--------------------------------------------------------------------------
 def refresh
   self.contents.clear
   cx = contents.text_size($data_system.words.gold).width
   self.contents.font.color = normal_color
   self.contents.draw_text(4, 0, 120-cx-2, 32, $game_party.gold.to_s, 2)
   self.contents.font.color = system_color
   self.contents.draw_text(124-cx, 0, cx, 32, $data_system.words.gold, 2)
 end
end


class Scene_Debug
 #--------------------------------------------------------------------------
 # * Object Initialization
 #     menu_index : command cursor's initial position
 #--------------------------------------------------------------------------
 def initialize(menu_index = 0)
   @menu_index = menu_index
 end
 #--------------------------------------------------------------------------
 # * Main Processing
 #--------------------------------------------------------------------------
 def main

   @command_window = Window_Command.new(160, ["Switches & variables", "Gold", "Location"])
   @command_window.index = @menu_index
   @spriteset = Spriteset_Map.new
   # Execute transition
   Graphics.transition
   # Main loop
   loop do
     # Update game screen
     Graphics.update
     # Update input information
     Input.update
     # Frame update
     update
     # Abort loop if screen is changed
     if $scene != self
       break
     end
   end
   # Prepare for transition
   Graphics.freeze
   # Dispose of windows
   @command_window.dispose

 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
   # Update windows
   @command_window.update

   update_command

 end
 #--------------------------------------------------------------------------
 # * Frame Update (when command window is active)
 #--------------------------------------------------------------------------
 def update_command
   # If B button was pressed
   if Input.trigger?(Input::B)
     # Play cancel SE
     $game_system.se_play($data_system.cancel_se)
     # Switch to map screen
     $scene = Scene_Map.new
     return
   end
   # If C button was pressed
   if Input.trigger?(Input::C)
     # Branch by command window cursor position
     case @command_window.index
     when 0  # Switches
       # Play decision SE
       $game_system.se_play($data_system.decision_se)
       # Switch to item screen
       $scene = Scene_Switches.new

     when 1  # gold
       # Play decision SE
       $game_system.se_play($data_system.decision_se)
       # Make status window active
$scene = Scene_Gold.new
     when 2  # location
       # Play decision SE
       $game_system.se_play($data_system.decision_se)
$scene = Scene_Location.new
     end
     return
   end
 end
 
 end







#==============================================================================
# ** Scene_Debug
#------------------------------------------------------------------------------
#  This class performs debug screen processing.
#==============================================================================

class Scene_Switches
 #--------------------------------------------------------------------------
 # * Main Processing
 #--------------------------------------------------------------------------
 def main
   # Make windows
   @left_window = Window_DebugLeft.new
   @right_window = Window_DebugRight.new
   @help_window = Window_Base.new(192, 352, 448, 128)
   @help_window.contents = Bitmap.new(406, 96)
   # Restore previously selected item
   @left_window.top_row = $game_temp.debug_top_row
   @left_window.index = $game_temp.debug_index
   @right_window.mode = @left_window.mode
   @right_window.top_id = @left_window.top_id
   # Execute transition
   Graphics.transition
   # Main loop
   loop do
     # Update game screen
     Graphics.update
     # Update input information
     Input.update
     # Frame update
     update
     # Abort loop if screen is changed
     if $scene != self
       break
     end
   end
   # Refresh map
   $game_map.refresh
   # Prepare for transition
   Graphics.freeze
   # Dispose of windows
   @left_window.dispose
   @right_window.dispose
   @help_window.dispose
 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
   # Update windows
   @right_window.mode = @left_window.mode
   @right_window.top_id = @left_window.top_id
   @left_window.update
   @right_window.update
   # Memorize selected item
   $game_temp.debug_top_row = @left_window.top_row
   $game_temp.debug_index = @left_window.index
   # If left window is active: call update_left
   if @left_window.active
     update_left
     return
   end
   # If right window is active: call update_right
   if @right_window.active
     update_right
     return
   end
 end
 #--------------------------------------------------------------------------
 # * Frame Update (when left window is active)
 #--------------------------------------------------------------------------
 def update_left
   # If B button was pressed
   if Input.trigger?(Input::B)
     # Play cancel SE
     $game_system.se_play($data_system.cancel_se)
     # Switch to map screen
     $scene = Scene_Debug.new
     return
   end
   # If C button was pressed
   if Input.trigger?(Input::C)
     # Play decision SE
     $game_system.se_play($data_system.decision_se)
     # Display help
     if @left_window.mode == 0
       text1 = "C (Enter) : ON / OFF"
       @help_window.contents.draw_text(4, 0, 406, 32, text1)
     else
       text1 = "Left : -1   Right : +1"
       text2 = "L (Pageup) : -10"
       text3 = "R (Pagedown) : +10"
       @help_window.contents.draw_text(4, 0, 406, 32, text1)
       @help_window.contents.draw_text(4, 32, 406, 32, text2)
       @help_window.contents.draw_text(4, 64, 406, 32, text3)
     end
     # Activate right window
     @left_window.active = false
     @right_window.active = true
     @right_window.index = 0
     return
   end
 end
 #--------------------------------------------------------------------------
 # * Frame Update (when right window is active)
 #--------------------------------------------------------------------------
 def update_right
   # If B button was pressed
   if Input.trigger?(Input::B)
     # Play cancel SE
     $game_system.se_play($data_system.cancel_se)
     # Activate left window
     @left_window.active = true
     @right_window.active = false
     @right_window.index = -1
     # Erase help
     @help_window.contents.clear
     return
   end
   # Get selected switch / variable ID
   current_id = @right_window.top_id + @right_window.index
   # If switch
   if @right_window.mode == 0
     # If C button was pressed
     if Input.trigger?(Input::C)
       # Play decision SE
       $game_system.se_play($data_system.decision_se)
       # Reverse ON / OFF
       $game_switches[current_id] = (not $game_switches[current_id])
       @right_window.refresh
       return
     end
   end
   # If variable
   if @right_window.mode == 1
     # If right button was pressed
     if Input.repeat?(Input::RIGHT)
       # Play cursor SE
       $game_system.se_play($data_system.cursor_se)
       # Increase variables by 1
       $game_variables[current_id] += 1
       # Maximum limit check
       if $game_variables[current_id] > 99999999
         $game_variables[current_id] = 99999999
       end
       @right_window.refresh
       return
     end
     # If left button was pressed
     if Input.repeat?(Input::LEFT)
       # Play cursor SE
       $game_system.se_play($data_system.cursor_se)
       # Decrease variables by 1
       $game_variables[current_id] -= 1
       # Minimum limit check
       if $game_variables[current_id] < -99999999
         $game_variables[current_id] = -99999999
       end
       @right_window.refresh
       return
     end
     # If R button was pressed
     if Input.repeat?(Input::R)
       # Play cursor SE
       $game_system.se_play($data_system.cursor_se)
       # Increase variables by 10
       $game_variables[current_id] += 10
       # Maximum limit check
       if $game_variables[current_id] > 99999999
         $game_variables[current_id] = 99999999
       end
       @right_window.refresh
       return
     end
     # If L button was pressed
     if Input.repeat?(Input::L)
       # Play cursor SE
       $game_system.se_play($data_system.cursor_se)
       # Decrease variables by 10
       $game_variables[current_id] -= 10
       # Minimum limit check
       if $game_variables[current_id] < -99999999
         $game_variables[current_id] = -99999999
       end
       @right_window.refresh
       return
     end
   end
 end
end


class Scene_Gold
 #--------------------------------------------------------------------------
 # * Object Initialization
 #     menu_index : command cursor's initial position
 #--------------------------------------------------------------------------
 def initialize(menu_index = 0)
   @menu_index = menu_index
 end
 #--------------------------------------------------------------------------
 # * Main Processing
 #--------------------------------------------------------------------------
 def main
   @command_window = Window_Command.new(160, ["set to zero", "-100", "-10", "-1", "+1", "+10", "+100", "*2", "*10"])
   @command_window.index = @menu_index
   @spriteset = Spriteset_Map.new
   @gold_window = Window_Gold.new
   @gold_window.x = 0
   @gold_window.y = 416
   # Execute transition
   Graphics.transition
   # Main loop
   loop do
     # Update game screen
     Graphics.update
     # Update input information
     Input.update
     # Frame update
     update
     # Abort loop if screen is changed
     if $scene != self
       break
     end
   end

   # Prepare for transition
   Graphics.freeze
   # Dispose of windows
   @command_window.dispose
   @gold_window.dispose
 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
   # Update windows
   @command_window.update
   @gold_window.update
   #@gold_window.update
   update_command
end
     
 #--------------------------------------------------------------------------
 # * Frame Update (when command window is active)
 #--------------------------------------------------------------------------
 def update_command
   # If B button was pressed
   if Input.trigger?(Input::B)
     # Play cancel SE
     $game_system.se_play($data_system.cancel_se)
     # Switch to map screen
     $scene = Scene_Debug.new
     return
   end
   # If C button was pressed
   if Input.trigger?(Input::C)
     # If command other than save or end game, and party members = 0
     if $game_party.actors.size == 0 and @command_window.index < 4
       # Play buzzer SE
       $game_system.se_play($data_system.buzzer_se)
       return
     end
     # Branch by command window cursor position
     case @command_window.index
     when 0  # set to zero
$game_party.gain_gold(-$game_party.gold)
@gold_window.refresh
     when 1  #
       # Play decision SE
       $game_system.se_play($data_system.decision_se)
       # Make status window active
     $game_party.gain_gold(-100)
@gold_window.refresh
     when 2  #
       # Play decision SE
       $game_system.se_play($data_system.decision_se)
$game_party.gain_gold(-10)
@gold_window.refresh
     when 3  #
       # Play decision SE
       $game_system.se_play($data_system.decision_se)
       # Make status window active
$game_party.gain_gold(-1)
@gold_window.refresh
     when 4  #
               $game_system.se_play($data_system.decision_se)
$game_party.gain_gold(1)
@gold_window.refresh
     when 5  # end game
               $game_system.se_play($data_system.decision_se)
$game_party.gain_gold(10)
@gold_window.refresh
     when 6
               $game_system.se_play($data_system.decision_se)
$game_party.gain_gold(100)
@gold_window.refresh
     when 7
               $game_system.se_play($data_system.decision_se)
$game_party.gain_gold($game_party.gold)
@gold_window.refresh
     when 8
               $game_system.se_play($data_system.decision_se)
$game_party.gain_gold($game_party.gold * 10 - $game_party.gold)
@gold_window.refresh
     return
     end
   end
 end
end

class Scene_Location
 #--------------------------------------------------------------------------
 # * Object Initialization
 #     menu_index : command cursor's initial position
 #--------------------------------------------------------------------------
 def initialize(menu_index = 0)
   @menu_index = menu_index
   
 end
 #--------------------------------------------------------------------------
 # * Main Processing
 #--------------------------------------------------------------------------
 def main

   @command_window = Window_Command.new(160, ["Next", "Previous"])
   @command_window.index = @menu_index
   @spriteset = Spriteset_Map.new
   # Execute transition
   Graphics.transition
   # Main loop
   loop do
     # Update game screen
     Graphics.update
     # Update input information
     Input.update
     # Frame update
     update
     # Abort loop if screen is changed
     if $scene != self
       break
     end
   end
   # Prepare for transition
   Graphics.freeze
   # Dispose of windows
   @command_window.dispose

 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
   # Update windows
   @command_window.update

   update_command

 end
 #--------------------------------------------------------------------------
 # * Frame Update (when command window is active)
 #--------------------------------------------------------------------------
 def update_command
   # If B button was pressed
   if Input.trigger?(Input::B)
     # Play cancel SE
     $game_system.se_play($data_system.cancel_se)
     # Switch to map screen
     $scene = Scene_Map.new
     return
   end
   # If C button was pressed
   if Input.trigger?(Input::C)
     # Branch by command window cursor position
     case @command_window.index
     when 0  #
       # Play decision SE
       $game_system.se_play($data_system.decision_se)
       # Switch to item screen
@va = $game_map.map_id
@va += 1
$game_map.setup(@va)
$game_map.update
   @spriteset = Spriteset_Map.new
     when 1  #
@va = $game_map.map_id
@va -= 1
$game_map.setup(@va)
$game_map.update
   @spriteset = Spriteset_Map.new
     end
     return
   end
 end
 
 end









Instructions
1. Insert script
2. press f9 to open debug menu, when playtesting.


Compatibility



Credits and Thanks




Author's Notes

Title: Re: [xp]Extended debug
Post by: Jackolas on April 16, 2010, 10:25:03 am
nice script but kinda useless since we have
http://forum.chaos-project.com/index.php/topic,118.0.html
Title: Re: [xp]Extended debug
Post by: Valdred on April 16, 2010, 11:55:17 am
oh, Well I didn't put much work into it, so it doesn't matter.  :)