UltimaForum

Skrypty [XP] - Debug Position

Melvin - Pią 20 Sty, 2012 01:35
Temat postu: Debug Position
~ Debug Position ~


Krótki opis:
Prosty skrypt, który pokazuję "X" i "Y" gracza na mapie i ekranie.
Konfiguracja według własnych potrzeb.

Autor:
Melvin

Kompatybilność:
RPG Maker XP

Skrypt:
Spoiler:

Kod:
#======================================================================
# Name: Debug Position
# Author: Melvin
# Verion: 1.0
#======================================================================
# KONFIGURACJA
#======================================================================
module Melvin
# Włączony:
  $DebugPosition = true # false
# Automatyczne odświerzanie:
  AutoRef = true # false
# Klawisz odświerzania: (jeśli wyłączone auto)
  InputRef = Input::L # Q
# Pozycja:
  Position = 3
# 1 - Prawy, górny róg
# 2 - Prawy, dolny róg
# 3 - Lewy górny róg
# 4 - Lewy, dolny róg
end
#======================================================================
class Scene_Map
  alias sm_mn_mel main
  def main
    @window_debug_position = Window_DebugPosition.new
    @window_debug_position.visible = $DebugPosition
    if Melvin::Position == 1
      @PosX = 480
      @PosY = 0
    elsif Melvin::Position == 2
      @PosX = 480
      @PosY = 320
    elsif Melvin::Position == 3
      @PosX = 0
      @PosY = 0
    elsif Melvin::Position == 4
      @PosX = 0
      @PosY = 320
    end
    @window_debug_position.x = @PosX
    @window_debug_position.y = @PosY
    sm_mn_mel
    @window_debug_position.dispose
  end
  alias sm_up_mel update
  def update
    if Melvin::Position == 1
      if $game_player.screen_x >= 464 and $game_player.screen_y <= 192
        @window_debug_position.opacity = 50
      else
        @window_debug_position.opacity = 150
      end
    elsif Melvin::Position == 2
      if $game_player.screen_x >= 464 and $game_player.screen_y >= 320
        @window_debug_position.opacity = 50
      else
        @window_debug_position.opacity = 150
      end
    elsif Melvin::Position == 3
      if $game_player.screen_x <= 176 and $game_player.screen_y <= 192
        @window_debug_position.opacity = 50
      else
        @window_debug_position.opacity = 150
      end
    elsif Melvin::Position == 4
      if $game_player.screen_x <= 176 and $game_player.screen_y >= 320
        @window_debug_position.opacity = 50
      else
        @window_debug_position.opacity = 150
      end
    end
    @window_debug_position.update
    if Melvin::AutoRef == true
      @window_debug_position.refresh
    else
      if Input.trigger?(Melvin::InputRef)
        @window_debug_position.refresh
      end
    end
    sm_up_mel
  end
end
class Window_DebugPosition < Window_Base
  def initialize
    super(0, 0, 160, 160)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 150
    refresh
  end
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(0, 0, 200, 32, "Player X")
    self.contents.font.color = normal_color
    self.contents.draw_text(0, 0, 200, 79, "Map: #{$game_player.x}")
    self.contents.draw_text(0, 0, 200, 111, "Screen: #{$game_player.screen_x}")
    self.contents.font.color = system_color
    self.contents.draw_text(0, 0, 200, 153, "Player Y")
    self.contents.font.color = normal_color
    self.contents.draw_text(0, 0, 200, 185, "Map: #{$game_player.y}")
    self.contents.draw_text(0, 0, 200, 217, "Screen: #{$game_player.screen_y}")
  end
end


Screeny:
Spoiler:



Dodatkowe informacje:
1. Wklej skrypt nad "Main" w Edytorze Skryptu.
2. Reszta instrukcji znajduje się w treści skryptu.

SaNq - Pią 20 Sty, 2012 11:08

Przyda sie :D
The Big Master - Sob 12 Sty, 2013 16:36

Uwaga w Polskim RM'ie wersja 1.00 nie widać napisów, pozwoliłem sobie dopisać 2 linijki aby było je widać, oto i skrypt na polaka 1.0:
Spoiler:


Kod:

#======================================================================
# Name: Debug Position
# Author: Melvin
# Poprawka: GuGuś
# Verion: 1.0
#======================================================================
# KONFIGURACJA
#======================================================================
module Melvin
# Włączony:
  $DebugPosition = true # false
# Automatyczne odświerzanie:
  AutoRef = true # false
# Klawisz odświerzania: (jeśli wyłączone auto)
  InputRef = Input::L # Q
# Pozycja:
  Position = 3
# 1 - Prawy, górny róg
# 2 - Prawy, dolny róg
# 3 - Lewy górny róg
# 4 - Lewy, dolny róg
end
#======================================================================
class Scene_Map
  alias sm_mn_mel main
  def main
    @window_debug_position = Window_DebugPosition.new
    @window_debug_position.visible = $DebugPosition
    if Melvin::Position == 1
      @PosX = 480
      @PosY = 0
    elsif Melvin::Position == 2
      @PosX = 480
      @PosY = 320
    elsif Melvin::Position == 3
      @PosX = 0
      @PosY = 0
    elsif Melvin::Position == 4
      @PosX = 0
      @PosY = 320
    end
    @window_debug_position.x = @PosX
    @window_debug_position.y = @PosY
    sm_mn_mel
    @window_debug_position.dispose
  end
  alias sm_up_mel update
  def update
    if Melvin::Position == 1
      if $game_player.screen_x >= 464 and $game_player.screen_y <= 192
        @window_debug_position.opacity = 50
      else
        @window_debug_position.opacity = 150
      end
    elsif Melvin::Position == 2
      if $game_player.screen_x >= 464 and $game_player.screen_y >= 320
        @window_debug_position.opacity = 50
      else
        @window_debug_position.opacity = 150
      end
    elsif Melvin::Position == 3
      if $game_player.screen_x <= 176 and $game_player.screen_y <= 192
        @window_debug_position.opacity = 50
      else
        @window_debug_position.opacity = 150
      end
    elsif Melvin::Position == 4
      if $game_player.screen_x <= 176 and $game_player.screen_y >= 320
        @window_debug_position.opacity = 50
      else
        @window_debug_position.opacity = 150
      end
    end
    @window_debug_position.update
    if Melvin::AutoRef == true
      @window_debug_position.refresh
    else
      if Input.trigger?(Melvin::InputRef)
        @window_debug_position.refresh
      end
    end
    sm_up_mel
  end
end
class Window_DebugPosition < Window_Base
  def initialize
    super(0, 0, 160, 160)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $defaultfonttype
    self.contents.font.size = $defaultfontsize
    self.opacity = 150
    refresh
  end
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(0, 0, 200, 32, "Player X")
    self.contents.font.color = normal_color
    self.contents.draw_text(0, 0, 200, 79, "Map: #{$game_player.x}")
    self.contents.draw_text(0, 0, 200, 111, "Screen: #{$game_player.screen_x}")
    self.contents.font.color = system_color
    self.contents.draw_text(0, 0, 200, 153, "Player Y")
    self.contents.font.color = normal_color
    self.contents.draw_text(0, 0, 200, 185, "Map: #{$game_player.y}")
    self.contents.draw_text(0, 0, 200, 217, "Screen: #{$game_player.screen_y}")
  end
end



Powered by phpBB modified by Przemo © 2003 phpBB Group