じ☆ve冰风 发表于 2026-7-6 22:18:14

Visible Debug 1.2

Visible Debug 1.2

mikb89

​

Introduction

Sometimes something goes wrong with events, switches and variables. You don't know what is happening, you just know they don't work.

With this script you can set in game a list of parameters to take under control and they'll be shown and updated in real time.

Features

The parameters list includes:


[*]switches and variables, events' self switches;
[*]events, player, actors, battlers character's graphic;
[*]events and player Through state and position;
[*]tile id of current player position;
[*]items, weapons, armors possession number;
[*]battlers' hp, sp, atk, pdef, str, dex, int, agi, state;
[*]actors' name & level (enemies don't have that);
[*]others useful datas you can check in configurations and can add your own.

Screenshots


http://img341.imageshack.us/img341/806/visibledebugxp.png


How to Use

Copy the script under Materials to use, then press F9 as usually and a choice window should appear.

Other infos in the comments.

Demo

Multilanguage demo v. 1.2 (805 K


http://www.mediafire.com/?fazb7tuowp9winy

Script

Spoiler                 Code:        
# Visible Debug v. 1.2 # XP version # by mikb89# Details: #Sometimes something goes wrong with events switches and variables. You don't #   know what is happening, you just know they don't work. #With this script you can set in game a list of parameters to take under #   control and they'll be shown and updated in real time. #This list includes: #   - switches and variables, events' self switches; #   - events, player, actors, battlers character's graphic; #   - events and player Through state and position; #   - tile id of current player position; #   - items, weapons, armors possession number; #   - battlers' hp, sp, atk, pdef, str, dex, int, agi, state; #   - actors' name & level (enemies don't have that); #   - others useful datas you can check here in configurations and can add your #   own.# Configurations: module VDEBUG   # Here's a list of terms you can change as you want:   HELP_TEXT = "Enter: add/remove; Pag: change list." # Help yourself!   # These are what appears on F9 press:   CALL_CLASSIC_DEBUG_TEXT = "Debug call"   CALL_VDEBUG_SETTINGS_TEXT = "Visible Debug data"   # These are lists names:   SWITCH_LIST_TEXT = "Switches"   VARIABLE_LIST_TEXT = "Variables"   ITEM_LIST_TEXT = "Items"   ACTOR_LIST_TEXT = "Actors"   EVENT_LIST_TEXT = "Events"   DATA_LIST_TEXT = "Infos"   WEAPON_LIST_TEXT = "Weapons"   ARMOR_LIST_TEXT = "Armors"   ENEMY_LIST_TEXT = "Enemies"    SHOW_EVENT_NAME = true # Show the event name. Set false for compatibility.   MOVE_AROUND_KEY = Input::ALT    # Pressing this key many times the debug sprite will move in the four angles    #of the screen and then hide.   TIME_TO_LOSE = 1    # Suggest to leave it as it is (1). It's the time to wait before data update.    # Don't set 0 or less or script will stop.    # The available data:   def self.collect_mainlist   poss = [] # You can change the order as you want, but can add nothing.   poss << [-1, $data_system.switches.size-1]   poss << [-2, $data_system.variables.size-1]   poss << [-3, $data_items.size-1]   poss << [-4, $data_actors.size-1]   poss <<    poss << [-5, $game_map.events.size] # No need of -1 because it's a Hash. D:   poss << [-6, self.useful_data.size-1]   poss << [-7, $data_weapons.size-1]   poss << [-8, $data_armors.size-1]   poss << [-9, [$game_troop.enemies.size, 8].max]   poss # Unless you know what you're doing, of course.   end   def self.useful_data   da = # First value must be nil.   da << [["Party:", $game_party.actors.size], # Open an array, add the item.            ["G:", $game_party.gold], # First value is a string shown...            ["S:", $game_party.steps], # ...second value is the variable to show.            ["T:", self.adjust_time(Graphics.frame_count)], # Remember the ,            ["Sav:", $game_system.save_count]] # Close the data array.            # Will show: "Party: 3 G: 333 S: 33 T: 3:33 Sav: 3" with something            #instead of 3.   da << ["Timer:", self.adjust_time($game_system.timer)]            # Even a single item can be added. And variable can also be a def.   da << [["Map id:", $game_map.map_id],            ["Size:", $game_map.width], ["x", $game_map.height]]            # You can, as an exercise, add for example the map name.      # Add here your own! We want YOU for items adding.      da # Here just returns the datas.   end   def self.adjust_time(value) # Example of a function. Returns formatted time.   value /= Graphics.frame_rate # Graphics.frame_rate = 1 second.   sec = value % 60 # Get the seconds.   value -= sec # Subtract them.   "#{value/60}:#{sprintf("%02d",sec)}" # Return min:sec formatted time string.   end end#Codename: vdebug   ($imported ||= {})[:mikb89_vdebug] = true# License: # - You can ask me to include support for other scripts as long as these scripts #   use the $imported = true; # - You can modify and even repost my scripts, after having received a response #   by me. For reposting it, anyway, you must have done heavy edit or porting, #   you can't do a post with the script as is; # - You can use my scripts for whatever you want, from free to open to #   commercial games. I'd appreciate by the way if you let me know about what #   you're doing; # - You must credit me, if you use this script or part of it.# * operations to let the Visible Debug configuration be availableclass Scene_Map #class Scene_Map#def call_debug() <- rewritten   def call_debug   # Clear debug call flag   $game_temp.debug_calling = false   # Play decision SE   $game_system.se_play($data_system.decision_se)   # Straighten player position   $game_player.straighten   # Switch to debug screen   $scene = Scene_ChoiceDebug.new   end endclass Scene_ChoiceDebug #class Scene_ChoiceDebug#def main()   def main   # Make command window   s1 = VDEBUG::CALL_CLASSIC_DEBUG_TEXT   s2 = VDEBUG::CALL_VDEBUG_SETTINGS_TEXT   s3 = "Cancel"   @command_window = Window_Command.new(320, )   @command_window.x = 320 - @command_window.width / 2   @command_window.y = 240 - @command_window.height / 2   # Execute transition   Graphics.transition   # Main loop   loop do       # Update game screen       Graphics.update       # Update input information       Input.update       # Frame Update       @command_window.update       if Input.trigger?(Input::         $game_system.se_play($data_system.cancel_se)         $scene = Scene_Map.new       elsif Input.trigger?(Input::C)         $game_system.se_play($data_system.decision_se)         $scene = case @command_window.index          when 0; Scene_Debug.new          when 1; Scene_VisibleDebug.new          when 2; Scene_Map.new         else; self; end       end       # Abort loop if screen is changed       if $scene != self         break       end   end   # Prepare for transition   Graphics.freeze   # Dispose of window   @command_window.dispose   end end# * operations to let the Visible Debug sprite work#class Game_Event#def name() (class Game_Event; def name; @event.name; end; end) if VDEBUG::SHOW_EVENT_NAME# why isn't the event name readable by default? WHY???class Scene_End   alias_method(:mainSE_b4_vdebug, :main) unless method_defined?(:mainSE_b4_vdebug) #class Scene_End#def main() <- aliased   def main   mainSE_b4_vdebug   # dispose the sprite on Shutdown and To title commands   $game_player.sdebug.dispose if !$scene || $scene.is_a?(Scene_Title)   end endThread.new{ wait = VDEBUG::TIME_TO_LOSE loop do   wait -= 1   ($game_player.sdebug.update rescue nil) if $game_player && $scene && wait == 0   wait = VDEBUG::TIME_TO_LOSE if wait == 0 end }# USARE QUESTO SOTTO PER DEBUG DATO CHE IL THREAD NON DA MESSAGGI DI ERRORE!!!# #class Scene_Battle#Map #alias upd update unless method_defined?(:upd) #def update #    #($game_player.sdebug.update) if $game_player #    upd #end #end#DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG#class Game_Player < Game_Character   # rely sprite on $game_player due to its reperibility. No, I'm not kidding :E #class Game_Player#def sdebug()   def sdebug   @sdebug ||= Sprite_Debug.new   end endclass Sprite_Debug < Sprite   attr_reader :infos #class Sprite_Debug#def initialize(i, pos, vp)   def initialize(i = nil, pos = 0, vp = nil)   if vp == nil; super(); else; super(vp); end # viewport?   self.infos = (i.is_a?(Array) ? i : ) # must be an array   self.z = 99999999 # a big value   self.opacity = 222 # little transparency   @last_values = []   @pos = pos - 1; move_around # position set   end #class Sprite_Debug#def move_around()   def move_around   @pos += 1; @pos %= 5 # increase position, modulate value   self.x = 320*(@pos%2) # right/left   self.y = 240*(@pos/2) # up/down/out   end #class Sprite_Debug#def infos=(i)   def infos=(i)   @infos = i   create_bitmap # once data change, we recreate the image   end #class Sprite_Debug#def marshal_dump()   def marshal_dump   [@infos, @pos, self.viewport] # values to save   end #class Sprite_Debug#def marshal_load(data)   def marshal_load(data)   initialize(data || nil, data || 0, data || nil)   end #class Sprite_Debug#def create_bitmap()   def create_bitmap   self.bitmap.dispose if self.bitmap && !self.bitmap.disposed?   h = @infos.size*24   self.bitmap = Bitmap.new(320,.max) # h is 0, if there's no item   for i in 0...@infos.size       next if @infos == nil || @infos.size < 2       draw_row(i, true) rescue nil   end   end #class Sprite_Debug#def draw_row(i, new)   def draw_row(i, new = false)   self.bitmap.fill_rect(0,i*24,320,24,Color.new(0,0,0,0)) unless new # no need                                                             # to clear if new   im = get_item(@infos) # get the bitmap then blt it. This way I can get   return unless im         #the same bitmap everywhere ^^   draw_placement(0, i*24)   self.bitmap.blt(0, i*24, im, im.rect)   im.dispose   end #class Sprite_Debug#def draw_placement(x, y)   def draw_placement(x, y)   self.bitmap.fill_rect(x+4,y+6,320-8,24-8,Color.new(0,0,0,128)) # bLackground   end #class Sprite_Debug#def collect(v)   def collect(v) # gets the relevant value(s) for each item   case v       when 0; collect_player       when 1; $game_switches]       when 2; $game_variables]       when 3; $game_party.item_number(v)       when 4; collect_actor($game_actors])       when 5; collect_event($game_map.events])       when 6; collect_data(VDEBUG::useful_data])       when 7; $game_party.weapon_number(v)       when 8; $game_party.armor_number(v)       when 9; collect_enemy($game_troop.enemies-1])   else; nil; end   end #class Sprite_Debug#def collect_player()   def collect_player   da = []   da << $game_player.character_name   da << $game_player.character_hue   da << $game_player.direction   da << $game_player.x   da << $game_player.y   da << ($game_player.through || ($DEBUG && Input.press?(Input::CTRL)))   for i in        da << $game_map.data[$game_player.x, $game_player.y, i]   end   da   end #class Sprite_Debug#def collect_actor(actor)   def collect_actor(actor)   da = []   da << actor.character_name   da << actor.character_hue   da << actor.name   da << actor.level   da << actor.hp   da << actor.maxhp   da << actor.sp   da << actor.maxsp   da << actor.states   da << actor.atk   da << actor.pdef   da << actor.str   da << actor.dex   da << actor.int   da << actor.agi   da   end #class Sprite_Debug#def collect_event(event)   def collect_event(event)   da = []   return da if event.nil?   da << event.character_name   da << event.character_hue   da << event.direction   da << event.x   da << event.y   da << event.through   for ss in ['A', 'B', 'C', 'D']       da << $game_self_switches[[$game_map.map_id, event.id, ss]]   end   da   end #class Sprite_Debug#def collect_data(data)   def collect_data(data)   da = []   return da if data.nil? || !data.is_a?(Array)   data = unless data.is_a?(Array)   return da if data.size < 1   for val in data       da << val   end   da   end #class Sprite_Debug#def collect_enemy(enemy)   def collect_enemy(enemy)   da = []   return da if enemy.nil?   da << enemy.battler_name   da << enemy.battler_hue   da << enemy.name   da << enemy.hp   da << enemy.maxhp   da << enemy.sp   da << enemy.maxsp   da << enemy.states   da << enemy.atk   da << enemy.pdef   da << enemy.str   da << enemy.dex   da << enemy.int   da << enemy.agi   da   end #class Sprite_Debug#def get_item(item, width, enabled)   def get_item(item, width = 320, enabled = true) # draw item in a bitmap   bit = Bitmap.new(width,24)   bit.font.color.alpha = blta = enabled ? 255 : 128   case item   when -9; draw_container(VDEBUG::ENEMY_LIST_TEXT, item, bit)   when -8; draw_container(VDEBUG::ARMOR_LIST_TEXT, item, bit)   when -7; draw_container(VDEBUG::WEAPON_LIST_TEXT, item, bit)   when -6; draw_container(VDEBUG::DATA_LIST_TEXT, item, bit)   when -5; draw_container(VDEBUG::EVENT_LIST_TEXT, item, bit)   when -4; draw_container(VDEBUG::ACTOR_LIST_TEXT, item, bit)   when -3; draw_container(VDEBUG::ITEM_LIST_TEXT, item, bit)   when -2; draw_container(VDEBUG::VARIABLE_LIST_TEXT, item, bit)   when -1; draw_container(VDEBUG::SWITCH_LIST_TEXT, item, bit)   when 0; draw_player(item, bit, blta)   when 1; draw_switch(item, bit, blta)   when 2; draw_variable(item, bit, blta)   when 3; draw_item(item, bit, blta)   when 4; draw_actor(item, bit, blta)   when 5; draw_event(item, bit, blta)   when 6; draw_data(item, bit, blta)   when 7; draw_weapon(item, bit, blta)   when 8; draw_armor(item, bit, blta)   when 9; draw_enemy(item, bit, blta)   else; bit.dispose; bit = nil   end   bit   end #class Sprite_Debug#def draw_container(txt, n, bitmap)   def draw_container(txt, n, bitmap)   bitmap.draw_text(12, 0, bitmap.width-32, 24, txt)   bitmap.draw_text(0, 0, bitmap.width, 24, n > 0 ? "(#{n})" : "", 2)   end #class Sprite_Debug#def draw_player(item, bitmap, blta)   def draw_player(item, bitmap, blta)   if item != nil       bitmap.blt(0, 0, get_character_icon(item, true), Rect.new(0,0,24,24), blta)       bitmap.draw_text(24, 0, bitmap.width, 24, "(#{item.x};#{item.y})")       tile = ""       for i in          tile += $game_map.data.to_s + (i != 2 ? ", " : "")       end       bitmap.draw_text(0, 0, bitmap.width-3, 24, "Tile: #{tile}", 2)       if (item.through || ($DEBUG && Input.press?(Input::CTRL)))         bitmap.font.size /= 2         bitmap.font.shadow = false if bitmap.font.respond_to?(:shadow)         col = false         for i in -1..2; for j in -1..1 # I could avoid all this, but...         next if i == j && i == 0         if i == 2             next if j != 0             col = true             i = 0         end         bitmap.font.color = col ? Color.new(0,0,0) : Color.new(99,33,55)         bitmap.draw_text(i, j+8, 23, 24, "T", 2)         break if i == j && j == 0         end; end       end   end   end #class Sprite_Debug#def draw_switch(n, bitmap, blta)   def draw_switch(n, bitmap, blta)   if n != nil       name = $data_system.switches       bitmap.blt(0, 0, get_text_icon("S"), Rect.new(0,0,24,24), blta)       bitmap.draw_text(24, 0, bitmap.width-32, 24, "[#{n}] #{name}:")       bitmap.draw_text(0, 0, bitmap.width, 24, " ? "N" : "FF"}]", 2)   end   end #class Sprite_Debug#def draw_variable(n, bitmap, blta)   def draw_variable(n, bitmap, blta)   if n != nil       name = $data_system.variables       bitmap.blt(0, 0, get_text_icon("V"), Rect.new(0,0,24,24), blta)       bitmap.draw_text(24, 0, bitmap.width-32, 24, "[#{n}] #{name}:")       bitmap.draw_text(0, 0, bitmap.width-3, 24, $game_variables.to_s, 2)   end   end #class Sprite_Debug#def draw_item(n, bitmap, blta)   def draw_item(n, bitmap, blta)   item = $data_items   if item != nil       bitmap.blt(0, 0, get_icon(item.icon_name), Rect.new(0,0,24,24), blta)       bitmap.draw_text(24, 0, bitmap.width, 24, item.name)       bitmap.draw_text(0, 0, bitmap.width-3, 24, $game_party.item_number(n).to_s, 2)   end   end #class Sprite_Debug#def draw_actor(n, bitmap, blta)   def draw_actor(n, bitmap, blta)   item = $game_actors   if item != nil       iw = bitmap.width       #bitmap.draw_text(24, 0, bitmap.width, 24, item.name) # draw name twice?       wb = Window_Base.new(-(iw+32),-56,iw+32,56) # I get a Window_Base for its       wb.contents = Bitmap.new(iw+32, 56)       wb.draw_actor_name(item, 24, -4)            #useful draw_this, draw_that       gs = iw-320       vals =        #vals -= 4; vals -= 4; vals << 0       wb.draw_actor_state(item, 160+gs, -4, 56)       wb.contents.font.size /= 2       wb.contents.font.shadow = false if wb.contents.font.respond_to?(:shadow)       col = false       for i in -1..2; for j in -1..1         next if i == j && i == 0         if i == 2         next if j != 0         col = true         i = 0         end         wb.contents.font.color = col ? Color.new(0,0,0) : wb.system_color         wb.contents.draw_text(i+106, j+vals, 16, 16, $data_system.words.hp)         wb.contents.draw_text(i+106, j+vals, 16, 16, $data_system.words.sp)         wb.contents.draw_text(i+6-1, j+8, 12, 24, "Lv")         wb.contents.draw_text(i+iw-112+16, j-4, 22, 24, $data_system.words.atk)         wb.contents.draw_text(i+iw-48+16, j-4, 22, 24, $data_system.words.pdef)         wb.contents.draw_text(i+iw-80+16, j-4, 22, 24, $data_system.words.str)         wb.contents.draw_text(i+iw-80+16, j+6, 22, 24, $data_system.words.dex)         wb.contents.draw_text(i+iw-112+16, j+6, 22, 24, $data_system.words.int)         wb.contents.draw_text(i+iw-48+16, j+6, 22, 24, $data_system.words.agi)         wb.contents.font.color = col ? Color.new(0,0,0) : wb.normal_color         wb.contents.draw_text(i, j+8, 23, 24, item.level.to_s, 2)         wb.contents.draw_text(i+iw-112+26, j-4, 18, 24, item.atk.to_s, 2)         wb.contents.draw_text(i+iw-48+26, j-4, 18, 24, item.pdef.to_s, 2)         wb.contents.draw_text(i+iw-80+26, j-4, 18, 24, item.str.to_s, 2)         wb.contents.draw_text(i+iw-80+26, j+6, 18, 24, item.dex.to_s, 2)         wb.contents.draw_text(i+iw-112+26, j+6, 18, 24, item.int.to_s, 2)         wb.contents.draw_text(i+iw-48+26, j+6, 18, 24, item.agi.to_s, 2)         wb.contents.draw_text(i+96+16+24, j+vals, 6, 16, "/", 1)         wb.contents.draw_text(i+96+16+24, j+vals, 6, 16, "/", 1)         wb.contents.draw_text(i+96+16+30, j+vals, 24, 16, item.maxhp.to_s)         wb.contents.draw_text(i+96+16+30, j+vals, 24, 16, item.maxsp.to_s)         unless col         wb.contents.font.color = wb.knockout_color if item.hp == 0         wb.contents.font.color = wb.crisis_color if item.hp <= item.maxhp / 4         end         wb.contents.draw_text(i+96+16, j+vals, 24, 16, item.hp.to_s, 2)         unless col         wb.contents.font.color = wb.knockout_color if item.sp == 0         wb.contents.font.color = wb.crisis_color if item.sp <= item.maxsp / 4         end         wb.contents.draw_text(i+96+16, j+vals, 24, 16, item.sp.to_s, 2)         break if i == j && j == 0       end; end       bitmap.blt(0, 0, get_character_icon(item), Rect.new(0,0,24,24), blta)       bitmap.blt(0, 0, wb.contents, wb.contents.rect, blta)       wb.dispose   end   end #class Sprite_Debug#def draw_event(n, bitmap, blta)   def draw_event(n, bitmap, blta)   item = $game_map.events   if item != nil       bitmap.blt(0, 0, get_character_icon(item, true), Rect.new(0,0,24,24), blta)       nm = VDEBUG::SHOW_EVENT_NAME ? item.name : ""       bitmap.draw_text(24, 0, bitmap.width-3, 24, "[#{item.id}](#{item.x};#{item.y})#{nm}")       loc = "ON:"       for ss in ['A', 'B', 'C', 'D']         loc += " " + ss + "," if $game_self_switches[[$game_map.map_id, item.id, ss]]       end       loc[-1] = "" if loc[-1].chr == ','       bitmap.draw_text(0, 0, bitmap.width, 24, loc, 2)       if item.through         bitmap.font.size /= 2         bitmap.font.shadow = false if bitmap.font.respond_to?(:shadow)         col = false         for i in -1..2; for j in -1..1         next if i == j && i == 0         if i == 2             next if j != 0             col = true             i = 0         end         bitmap.font.color = col ? Color.new(0,0,0) : Color.new(99,33,55)         bitmap.draw_text(i, j+8, 23, 24, "T", 2) if item.through         break if i == j && j == 0         end; end       end   else       bitmap.blt(0, 0, get_text_icon(n.to_s), Rect.new(0,0,24,24), blta)       bitmap.draw_text(0, 0, bitmap.width, 24, "EV#{sprintf("%03d", n)}", 1)   end   end #class Sprite_Debug#def draw_data(n, bitmap, blta)   def draw_data(n, bitmap, blta)   item = VDEBUG::useful_data   if item != nil && item.is_a?(Array)       item = unless item.is_a?(Array)       return if item.size < 1       str = ""       for val in item         str += val + " #{val} "       end       str[-1] = "" if str[-1].chr == " "       bitmap.draw_text(0, 0, bitmap.width, 24, str, 1)   end   end #class Sprite_Debug#def draw_weapon(n, bitmap, blta)   def draw_weapon(n, bitmap, blta)   item = $data_weapons   if item != nil       bitmap.blt(0, 0, get_icon(item.icon_name), Rect.new(0,0,24,24), blta)       bitmap.draw_text(24, 0, bitmap.width, 24, item.name)       bitmap.draw_text(0, 0, bitmap.width-3, 24, $game_party.weapon_number(n).to_s, 2)   end   end #class Sprite_Debug#def draw_armor(n, bitmap, blta)   def draw_armor(n, bitmap, blta)   item = $data_armors   if item != nil       bitmap.blt(0, 0, get_icon(item.icon_name), Rect.new(0,0,24,24), blta)       bitmap.draw_text(24, 0, bitmap.width, 24, item.name)       bitmap.draw_text(0, 0, bitmap.width-3, 24, $game_party.armor_number(n).to_s, 2)   end   end #class Sprite_Debug#def draw_enemy(n, bitmap, blta)   def draw_enemy(n, bitmap, blta)   item = $game_troop.enemies   iw = bitmap.width   if item != nil       wb = Window_Base.new(-(iw+32),-56,iw+32,56) # I get a Window_Base for its       wb.contents = Bitmap.new(iw+32, 56)       wb.draw_actor_name(item, 24, -4)            #useful draw_this, draw_that       gs = iw-320       vals =        #vals -= 4; vals -= 4; vals << 0       wb.draw_actor_state(item, 160+gs, -4, 56)       wb.contents.font.size /= 2       wb.contents.font.shadow = false if wb.contents.respond_to?(:shadow)       col = false       for i in -1..2; for j in -1..1         next if i == j && i == 0         if i == 2         next if j != 0         col = true         i = 0         end         wb.contents.font.color = col ? Color.new(0,0,0) : wb.system_color         wb.contents.draw_text(i+106, j+vals, 16, 16, $data_system.words.hp)         wb.contents.draw_text(i+106, j+vals, 16, 16, $data_system.words.sp)         wb.contents.draw_text(i+iw-112+16, j-4, 22, 24, $data_system.words.atk)         wb.contents.draw_text(i+iw-48+16, j-4, 22, 24, $data_system.words.pdef)         wb.contents.draw_text(i+iw-80+16, j-4, 22, 24, $data_system.words.str)         wb.contents.draw_text(i+iw-80+16, j+6, 22, 24, $data_system.words.dex)         wb.contents.draw_text(i+iw-112+16, j+6, 22, 24, $data_system.words.int)         wb.contents.draw_text(i+iw-48+16, j+6, 22, 24, $data_system.words.agi)         wb.contents.font.color = col ? Color.new(0,0,0) : wb.normal_color         #wb.contents.draw_text(i, j+8, 23, 24, item.letter, 2)         wb.contents.draw_text(i+iw-112+26, j-4, 18, 24, item.atk.to_s, 2)         wb.contents.draw_text(i+iw-48+26, j-4, 18, 24, item.pdef.to_s, 2)         wb.contents.draw_text(i+iw-80+26, j-4, 18, 24, item.str.to_s, 2)         wb.contents.draw_text(i+iw-80+26, j+6, 18, 24, item.dex.to_s, 2)         wb.contents.draw_text(i+iw-112+26, j+6, 18, 24, item.int.to_s, 2)         wb.contents.draw_text(i+iw-48+26, j+6, 18, 24, item.agi.to_s, 2)         wb.contents.draw_text(i+96+16+24, j+vals, 6, 16, "/", 1)         wb.contents.draw_text(i+96+16+24, j+vals, 6, 16, "/", 1)         wb.contents.draw_text(i+96+16+30, j+vals, 24, 16, item.maxhp.to_s)         wb.contents.draw_text(i+96+16+30, j+vals, 24, 16, item.maxsp.to_s)         unless col         wb.contents.font.color = wb.knockout_color if item.hp == 0         wb.contents.font.color = wb.crisis_color if item.hp <= item.maxhp / 4         end         wb.contents.draw_text(i+96+16, j+vals, 24, 16, item.hp.to_s, 2)         unless col         wb.contents.font.color = wb.knockout_color if item.sp == 0         wb.contents.font.color = wb.crisis_color if item.sp <= item.maxsp / 4         end         wb.contents.draw_text(i+96+16, j+vals, 24, 16, item.sp.to_s, 2)         break if i == j && j == 0       end; end       bitmap.blt(0, 0, get_enemy_icon(item), Rect.new(0,0,24,24), blta)       bitmap.blt(0, 0, wb.contents, wb.contents.rect, blta)       wb.dispose   else       bitmap.blt(0, 0, get_text_icon(n.to_s), Rect.new(0,0,24,24), blta)       bitmap.draw_text(0, 0, iw, 24, "...", 1)   end   end #class Sprite_Debug#def get_icon(index)   def get_icon(index) # get an icon from cache, recache it   @icache ||= {}   return @icache if @icache   bit = RPG::Cache.icon(index).clone   @icache = bit   bit   end #class Sprite_Debug#def get_character_icon(chara, dir)   def get_character_icon(chara, dir = false) # get iconized character from...   #if && !dir # actors here have icons ^^   ## REQUIRE Something   #    return get_icon(chara.battler_icon)   ## END REQUIRE   #end   @icache ||= {}   c_id = chara.character_name + "_" + chara.character_hue.to_s + "_" +            (dir ? chara.direction.to_s : "2")   return @icache if @icache   if dir       cp = chara.clone       cp.transparent = true       return Bitmap.new(24, 24) if !cp.tile_id       sc = Sprite_Character.new(nil, cp) # ...a Sprite_Character or...       bit = Bitmap.new(24, 24)       bit.blt((24-sc.src_rect.width)/2,(24-sc.src_rect.height)/2,sc.bitmap, sc.src_rect)       sc.dispose       cp = nil   else       wb = Window_Base.new(-56,-56,56,56) # ...a Window_Base...       wb.contents = Bitmap.new(56, 56)       wb.draw_actor_graphic(chara,12,33)       bit = wb.contents.clone       wb.dispose   end   @icache = bit # ...and cache it   bit   end #class Sprite_Debug#def get_text_icon(text)   def get_text_icon(text) # get an iconized text, like S, V or numbers   @icache ||= {}   return @icache if @icache   bit = Bitmap.new(24,24)   bit.font.shadow = false if bit.font.respond_to?(:shadow)   bit.font.italic = true   bit.font.bold = true   bit.font.size -= 1   bit.font.color = Color.new(81,59,59, 128)   for i in -2..2; for j in -1..1 # draw black text many times around       bit.draw_text(i,j+2,24,24,text,1)   end; end   bit.font.color = Color.new(255,255,255)   bit.draw_text(0,2,24,24,text,1)   @icache = bit   bit   end #class Sprite_Debug#def get_enemy_icon(enemy)   def get_enemy_icon(enemy) # get an iconized enemy graphic   @icache ||= {}   #if # battlers here already have an icon ^^   ## REQUIRE Something   #    ih = enemy.icon_hue   #    id = enemy.battler_icon.to_s + "_" + ih.to_s   #    return @icache if @icache   #    bit = get_icon(enemy.battler_icon).clone   #    bit.hue_change(ih) if ih != 0   ## END REQUIRE   #else       id = enemy.battler_name + "_" + enemy.battler_hue.to_s       return @icache if @icache       bit = Bitmap.new(24,24)       sb = Sprite_Battler.new(nil, enemy) # get the bitmap from a Sprite_Battler       sb.opacity = 0 # don't wanna see the full battler       sb.update # let the graphic be loaded       #RPG::Cache.battler(@battler_name, @battler_hue) # if something goes wrong       sb.dispose if sb.bitmap.nil? || sb.bitmap.disposed? # no graphic?       return bit if sb.disposed?       b2 = Bitmap.new(sb.src_rect.width, sb.src_rect.height) # I get a new bitmap       b2.blt(0, 0, sb.bitmap, sb.src_rect)                   #within src_rect       sb.bitmap = b2 # disposing sb even its bitmap will be disposed       if b2.width <= 24 || b2.height <= 24 # if little bitmap just center it         bit.blt((24-b2.width)/2, (24-b2.height)/2, b2, b2.rect)       else # else resize         fact = (b2.width > b2.height ? b2.height : b2.width)/24.0         nw = b2.width/fact; nh = b2.height/fact         bit.stretch_blt(Rect.new((24-nw)/2, (24-nh)/2, nw, nh), b2, b2.rect)       end       sb.dispose   #end   @icache = bit   bit   end #class Sprite_Debug#def update()   def update   move_around if Input.trigger?(VDEBUG::MOVE_AROUND_KEY)   for i in 0...@infos.compact.size       v = @infos       # set every new value and redraw if needed       draw_row(i) if @last_values != (@last_values = collect(v))   end   super   end end# * operation to create a Visible Debug options screenclass Window_VDList < Window_Selectable   # a silly, simple, window that handle a list   attr_reader :data #class Window_VDList#def initialize(x, y, list, ctd)   def initialize(x, y, list = [], ctd = false)   super(x, y, 320, 480-y)   @column_max = 1   @cantdisable = ctd   self.index = 0   set_list(list)   end #class Window_VDList#def set_list(list)   def set_list(list)   @data = list   @item_max = @data.size   self.index = @item_max - 1 if self.index > 0 && @item_max < self.index   self.contents.dispose if self.contents && !self.contents.disposed?   self.contents = Bitmap.new(width - 32, [@item_max, 1].max * 32)   refresh   end #class Window_VDList#def enabled?(index)   def enabled?(index)   return true if @cantdisable   !$game_player.sdebug.infos.include?(@data)   end #class Window_VDList#def item()   def item   return @data   end #class Window_VDList#def add_item(it)   def add_item(it)   @data.push(it)   set_list(@data.compact)   end #class Window_VDList#def remove_item(it)   def remove_item(it)   remove(@data.index(it))   end #class Window_VDList#def remove(index)   def remove(index)   return if index == nil   return if index < 0   return if index >= @data.size   @data.delete_at(index)   set_list(@data)   end #class Window_VDList#def refresh()   def refresh   self.contents.clear   for i in 0...@item_max       draw_item(i)   end   end #class Window_VDList#def draw_item(index)   def draw_item(index)   rect = Rect.new(0, 4 + index * 32, width - 32, 24)   self.contents.fill_rect(rect, Color.new(0,0,0,0))   return if @data.nil?   im = $game_player.sdebug.get_item(@data, rect.width-4, enabled?(index))   self.contents.blt(rect.x, rect.y, im, im.rect) if im   im.dispose if im   end endclass Scene_VisibleDebug   # a silly, simple, scene #class Scene_VisibleDebug#def main()   def main   @help_window = Window_Help.new   @help_window.set_text(VDEBUG::HELP_TEXT)   ips = @help_window.height   # third list window parameter is the list, fourth is the cantdisable value   @mainlist_window = Window_VDList.new(0, ips, VDEBUG::collect_mainlist)   @debuglist_window = Window_VDList.new(@mainlist_window.width, ips,                                           $game_player.sdebug.infos, true)   @elementlist_window = Window_VDList.new(0, ips)   @elementlist_window.visible = false   @elementlist_window.active = false   @debuglist_window.active = false      # 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      @help_window.dispose   @mainlist_window.dispose   @debuglist_window.dispose   @elementlist_window.dispose   end #class Scene_VisibleDebug#def update()   def update   @help_window.update   @mainlist_window.update   @debuglist_window.update   @elementlist_window.update   if @mainlist_window.active       update_mainlist   elsif @debuglist_window.active       update_debuglist   elsif @elementlist_window.active       update_elementlist   end   end #class Scene_VisibleDebug#def update_mainlist()   def update_mainlist   if Input.trigger?(Input::       $game_system.se_play($data_system.cancel_se)       $scene = Scene_Map.new       return   elsif Input.trigger?(Input::C)       $game_system.se_play($data_system.decision_se)       it = @mainlist_window.item       if it >= 0 # if item's a item:         if @mainlist_window.enabled?(@mainlist_window.index) # add/remove         @debuglist_window.add_item(it)         else         @debuglist_window.remove_item(it)         end         $game_player.sdebug.infos = @debuglist_window.data # update         @mainlist_window.draw_item(@mainlist_window.index) # redraw       else # if item's a group:         process_elementlist_open(it) # open the sub-list         @mainlist_window.active = false         @elementlist_window.active = true       end   elsif Input.trigger?(Input::R) || Input.trigger?(Input::L)       $game_system.se_play($data_system.cursor_se)       @mainlist_window.active = false       @debuglist_window.active = true   end   end #class Scene_VisibleDebug#def update_debuglist()   def update_debuglist   if Input.trigger?(Input::       $game_system.se_play($data_system.cancel_se)       $scene = Scene_Map.new       return   elsif Input.trigger?(Input::C)       $game_system.se_play($data_system.decision_se)       @debuglist_window.remove(@debuglist_window.index) # remove the item       $game_player.sdebug.infos = @debuglist_window.data # update       @mainlist_window.refresh # redraw   elsif Input.trigger?(Input::R) || Input.trigger?(Input::L)       $game_system.se_play($data_system.cursor_se)       @mainlist_window.active = true       @debuglist_window.active = false   end   end #class Scene_VisibleDebug#def update_elementlist()   def update_elementlist   if Input.trigger?(Input::       $game_system.se_play($data_system.cancel_se)       @elementlist_window.active = false       @mainlist_window.active = true       @mainlist_window.visible = true       @elementlist_window.visible = false   elsif Input.trigger?(Input::C)       $game_system.se_play($data_system.decision_se)       it = @elementlist_window.item       if @elementlist_window.enabled?(@elementlist_window.index) # add/remove         @debuglist_window.add_item(it)       else         @debuglist_window.remove_item(it)       end       $game_player.sdebug.infos = @debuglist_window.data # update       @elementlist_window.draw_item(@elementlist_window.index) # redraw   end   end #class Scene_VisibleDebug#def process_elementlist_open(it)   def process_elementlist_open(it) # it contains the type and the size   # collect elements of the group   vals = []   for d in 1..it # starting from 1, because there aren't IDs 0      vals << *-1,d] # the type must be positive   end   # and let the window appears   @elementlist_window.set_list(vals)   @elementlist_window.index = 0   @mainlist_window.visible = false   @elementlist_window.visible = true   end end





Also visible on Pastebin.FAQ

Saves will contain the actual in-game list. It is possible to load previous saves, but to continue using those done while using this script, if you remove it, you can use a little piece of code you can find in the demo.

Credit and Thanks

Thanks Silver Element for having me inspired the idea


Author's Notes

N/A


本贴来自国际rpgmaker官方论坛作者:mikb89处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/visible-debug-1-2.3460/
页: [1]
查看完整版本: Visible Debug 1.2