Chaos Project

RPG Maker => RPG Maker Scripts => RMXP Script Database => Topic started by: ForeverZer0 on April 28, 2010, 06:23:03 pm

Title: [XP] Self-Switch Debug Menu
Post by: ForeverZer0 on April 28, 2010, 06:23:03 pm
Self-Switch Debug Menu
Authors: ForeverZer0
Version: 1.0
Type: Debug Add-On
Key Term: Game Utility



Introduction

This is just a simple add-on for debug mode. Will allow you to change event's self-switches during test-play by calling a small secondary debug menu. For the sake of keeping it simple, it will only be able to change self-switches of events on the current map.


Features




Screenshots

None.


Demo

None.


Script

Click here for the script.
Spoiler: ShowHide

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
# Self Switch Debug Menu 
# Author: ForeverZer0
# Date: 4.28.2010
# Version: 1.0
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#
# Explanation:
#
#   Very simple. Lets you change event's self-switches the same as you can
#   change the game switches by pressing F9 during test play. Only applies
#   to events on the current map.
#
# Instructions:
#
#   Just press F7 to bring up the menu. If you do want to use F7, just scroll
#   down a few lines and find (Input::F7). Change it to what you wish.
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:

#-------------------------------------------------------------------------------
# ** Scene_Map
#-------------------------------------------------------------------------------

class Scene_Map
 
  alias zer0_self_switch_debug_upd update
  def update
    zer0_self_switch_debug_upd
    if Input.trigger?(Input::F7)
      $scene = Scene_SelfSwitch_Debug.new
    end
  end
end

#-------------------------------------------------------------------------------
# ** Window_SelfSwitch_Debug
#-------------------------------------------------------------------------------

class Window_SelfSwitch_Debug < Window_Selectable
 
  attr_accessor :event
 
  def initialize
    super(0, 0, 192, 192)
    self.contents = Bitmap.new(width - 32, height - 32)
    @map = $game_map.map_id
    self.index, @item_max, self.back_opacity = 0, 5, 160
    refresh
  end
 
  def refresh
    return if @event == nil
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(4, 0, 160, 32, 'Event ID:')
    self.contents.draw_text(12, 32, 160, 32, 'A')
    self.contents.draw_text(12, 64, 160, 32, 'B')
    self.contents.draw_text(12, 96, 160, 32, 'C')
    self.contents.draw_text(12, 128, 160, 32, 'D')
    if $game_map.events[@event] != nil
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    self.contents.draw_text(-4, 0, 160, 32, @event.to_s, 2)
    if $game_map.events[@event] != nil
      a = $game_self_switches[[@map, @event, 'A']].to_s
      b = $game_self_switches[[@map, @event, 'B']].to_s
      c = $game_self_switches[[@map, @event, 'C']].to_s
      d = $game_self_switches[[@map, @event, 'D']].to_s
    else
      a = b = c = d = 'nil'
    end
    self.contents.draw_text(-4, 32, 160, 32, a, 2)
    self.contents.draw_text(-4, 64, 160, 32, b, 2)
    self.contents.draw_text(-4, 96, 160, 32, c, 2)
    self.contents.draw_text(-4, 128, 160, 32, d, 2)
  end
 
  def event=(event)
    @event = event if @event != event
    refresh
  end
end

#-------------------------------------------------------------------------------
# ** Scene_SelfSwitch_Debug
#-------------------------------------------------------------------------------

class Scene_SelfSwitch_Debug
 
  def main
    @mapback = Spriteset_Map.new
    @window = Window_SelfSwitch_Debug.new
    @window.event = 1
    Graphics.transition
    loop {Graphics.update; Input.update; update; break if $scene != self}
    [@mapback, @window].each {|sprite| sprite.dispose}
  end
 
  def update
    [@mapback, @window].each {|sprite| sprite.update}
    if Input.trigger?(Input::B)
      $game_map.refresh
      $scene = Scene_Map.new
    end
    if @window.index == 0
      if Input.repeat?(Input::LEFT)
        @window.event -= 1 if @window.event > 1
      elsif Input.repeat?(Input::RIGHT)
        @window.event += 1 if @window.event < 999
      end
    else
      if Input.trigger?(Input::LEFT) || Input.trigger?(Input::RIGHT)
        return if $game_map.events[@window.event] == nil
        switch = $game_self_switches
        map = $game_map.map_id
        id = @window.event
        case @window.index
        when 1
          switch[[map, id, 'A']] = switch[[map, id, 'A']] == true ? false : true
        when 2
          switch[[map, id, 'B']] = switch[[map, id, 'B']] == true ? false : true
        when 3
          switch[[map, id, 'C']] = switch[[map, id, 'C']] == true ? false : true
        when 4
          switch[[map, id, 'D']] = switch[[map, id, 'D']] == true ? false : true
        end
        @window.refresh
      end
    end
  end
end



Instructions

Place script above main and below Scene_Map. Press F7 (configurable) to call menu during Debug.


Compatibility

No known issues.


Credits and Thanks




Author's Notes

None.
Title: Re: [XP] Self-Switch Debug Menu
Post by: WhiteRose on April 28, 2010, 06:49:14 pm
Amazing! This was one of the most important features missing from Blizz's Debug Menu. Great work!