UltimaForum

Wsparcie [VX] - Hud

Tjef - Sro 13 Paź, 2010 20:23
Temat postu: Hud
Zaczynamy...


Mam taki fajny Hud z pewnej stronki, ale wyskakuje mi błąd

Skrypt:
Spoiler:

Kod:

################################################################################
#                                                                              #
#                      ~~~~~ Copyright 2009 SojaBird ~~~~~                     #
#                               HUD BluePrint v3.2                             #
#                                                                              #
################################################################################

# To toggle the hud's display, just do a callscript "hud"
# To set the hud's display, just do a callscript "hud(true)" or "hud(false)"

module Module_Name; WLH = Window_Base::WLH
################################################################################
# User Customazation
  Start_Display = true #true/false
  Opacity = 100 #0-255
  BG_Display = true #true/false
  Hide = true #true/false
  EXP_NAME = "E"
################################################################################
# Don't touch below (if ure're not a scripter)
################################################################################
=begin #########################################################################
Some standard value's you might want to use are allready pre-defiend so that you
don't have to write the whole function for your self anymore.
Here follows a list: (just copy+past and fill in the value's to let it work)
  * draw_actor_graphic(actor, x, y)
  * draw_actor_face(actor, x, y, size = 96)
  * draw_actor_name(actor, x, y)
  * draw_actor_class(actor, x, y)
  * draw_actor_level(actor, x, y)
  * draw_actor_state(actor, x, y, width = 96)
  * draw_actor_hp(actor, x, y, width = 120)
  * draw_actor_mp(actor, x, y, width = 120)
  * draw_actor_parameter(actor, x, y, type)
      FOR TYPE: 0=atk, 1=def, 2=spi, 3=agi
  * draw_item_name(item, x, y, enabled = true)
  * draw_currency_value(value, x, y, width)
 
  Custom new standard functions:
  * draw_actor_exp(actor, x, y, width = 120)
=end ###########################################################################
################################################################################
  def xywh
    @x = 0 #Set the x-position
    @y = 0 #Set the y-position
    @w = 96+32 #Set the width
    @h = 72+24+32 #Set the height
    return[@x, @y, @w, @h]
  end; def hud_values #Set the value's that you're using (also used at refresh)
    @actor = $game_party.members[@index]
    @temp_states = @actor.states
    #Example: @actor = $game_party.members[0]
  end; def hud_contents #Set the things you want to draw
    draw_actor_graphic(@actor, 14, 42)
    draw_actor_hp(@actor, 32, 0, 93-32)
    draw_actor_mp(@actor, 32, 24, 96-32)
    draw_actor_exp(@actor, 0, 48, 96)
    draw_actor_state(@actor, 0, 72, 96)
    #Example: draw_actor_hp(@actor, x, y)
  end; def hud_refresh?
    if @temp_actor != @actor or
    @temp_actor.character_name != @actor.character_name or
    @temp_actor.character_index != @actor.character_index or
    @temp_actor.hp != @actor.hp or
    @temp_actor.mp != @actor.mp or
    @temp_actor.exp != @actor.exp or
    @temp_states != @actor.states
    @temp_states = @actor.states
    #Example: if @actor != $game_party.members[0]
    return true; end
  end
end
################################################################################
# Don't touch below
################################################################################

################################################################################
# Call script function
################################################################################
def hud(arg = nil)
  $game_system.hud_display = !$game_system.hud_display if arg == nil
  $game_system.hud_display = arg if arg != nil
end
################################################################################
#------------------------------------------------------------
# * Hud_Name: Create Hud window
#------------------------------------------------------------
class Hud_Name < Window_Base
  include Module_Name
 
  attr_reader :index
 
  def initialize(index)
    @index = index
    super(xywh[0],xywh[1],xywh[2],xywh[3])
    self.visible = $game_system.hud_display
    self.opacity = Opacity
    self.opacity = 0 if !BG_Display
    hide_status if Hide
    hud_values
    refresh
  end
 
  def refresh
    contents.clear
    hud_values
    hud_contents
  end
 
  def hide_status
    if Hide
      if $game_player.screen_x + 16 > self.x and
      $game_player.screen_y + 4 > self.y and
      $game_player.screen_x - 16 < self.x + self.width and
      $game_player.screen_y - 28 < self.y + self.height
        self.opacity = Opacity if BG_Display
        self.contents_opacity = Opacity
      else
        self.opacity = 255 if BG_Display
        self.contents_opacity = 255
      end
    end
  end
 
  def update
    self.visible = $game_system.hud_display
    return if !self.visible
    refresh if hud_refresh?
    hide_status if Hide
  end
end

#------------------------------------------------------------
# * Scene_Map: Attach HUD to map
#------------------------------------------------------------
class Scene_Map < Scene_Base
  alias start_hud_name start
  alias terminate_hud_name terminate
  alias update_hud_name update
  def start
    start_hud_name
    @index = 0
    new_hud
  end
  def terminate
    @hud_name.dispose
    terminate_hud_name
  end
  def update
    update_hud_name
    @hud_name.update
    return if !@hud_name.visible
    if Input.trigger?(Input::R)
      if @index == $game_party.members.size - 1
        @index = 0
      else
        @index += 1
      end
    elsif Input.trigger?(Input::L)
      if @index == 0
        @index = $game_party.members.size - 1
      else
        @index -= 1
      end
    end
    new_hud if @index != @hud_name.index
  end
  def new_hud
    @hud_name.dispose if !@hud_name.nil?
    @hud_name = Hud_Name.new(@index)
  end
end

#------------------------------------------------------------
# * Game_System: Check for display
#------------------------------------------------------------
class Game_System
  alias hud_initialize initialize
  attr_accessor :hud_display
  def initialize
    hud_initialize
    @hud_display = Module_Name::Start_Display
  end
end

#------------------------------------------------------------
# * Window_Base: Some new standard function
#------------------------------------------------------------
class Window_Base < Window
  include Module_Name
 
  def draw_actor_exp(actor, x, y, width = 120)
    s1 = actor.exp_s
    s2 = actor.next_rest_exp_s + s1
    if s1.is_a? String or s2.is_a? String
      s1 = actor.exp
      s2 = actor.exp
    end
    draw_actor_exp_gauge(actor, x, y, s1, s2, width)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 30, WLH, EXP_NAME)
    self.contents.font.color = normal_color
    last_font_size = self.contents.font.size
    xr = x + width
    if width < 120
      self.contents.draw_text(xr - 44, y, 44, WLH, s1, 2)
    else
      self.contents.draw_text(xr - 99, y, 44, WLH, s1, 2)
      self.contents.font.color = normal_color
      self.contents.draw_text(xr - 55, y, 11, WLH, "/", 2)
      self.contents.draw_text(xr - 44, y, 44, WLH, s2, 2)
    end
  end
 
  def draw_actor_exp_gauge(actor, x, y, s1, s2, width = 120)
    gw = width * s1 / s2
    gc1 = text_color(31)
    gc2 = text_color(27)
    self.contents.fill_rect(x, y + WLH - 8, width, 6, gauge_back_color)
    self.contents.gradient_fill_rect(x, y + WLH - 8, gw, 6, gc1, gc2)
  end
end


Screen do niego:


I WYSKAKUJĄCY BŁĄD:
Spoiler:

http://img801.imageshack.us/i/pngy.png/




Nie wiem o co kaman...

Czy chodzi o kombatybilność, czy o co...


POmożecie ? :->

radek02 - Czw 14 Paź, 2010 07:17

sprawdź 51 linijkę skryptu .
RATI - Czw 14 Paź, 2010 10:18

Najwyraźniej chodzi o kompatybilność, bo na pustym projekcie działa bez zarzutu.
Tjef - Czw 14 Paź, 2010 12:58

Też przed chwilą próbowałem na nowym projekcie :-P i działa.
Ale zdziwiło mnie to, że skopiowałem do tego pustego projektu
wszystkie skrypty, które mam i tam działa, a u mnie nie....
Może kiedyś się bawiłem w systemowych skryptach i coś musiałem
zbroić.... :-P

Ayene - Pią 15 Paź, 2010 08:51

No to ja teraz Ciebie oświecę ;-) Wyskakuje błąd, bo nie masz nikogo w drużynie. Jak ma pobrać dane na temat statusów z drużyny, skoro jest ona pusta. Doszukujecie się wad w skryptach, zamiast w pierwszej kolejności sprawdzić, czy sami nie popełniacie gdzieś błędu.
Tjef - Pią 15 Paź, 2010 17:50

Ayene, problem w tym, że mam ludzi w drużynie :-/ .
Jeszcze tydzień temu HUD mi działał ...

Ayene - Pią 15 Paź, 2010 18:44

ThiefStory, no dobrze. Ale warunkiem działania skryptu jest ktokolwiek w drużynie. Może być nawet 'pan X', który nie ma charseta, ale musi ktoś być. Inaczej działaś nie będzie. Chyba że wprowadzi się korekty w skrypcie.
Tjef - Pią 15 Paź, 2010 19:03

Coś się chyba nie zrozumieliśmy...
Od początku gry (załóżmy, że ten 'Pan X') jest w drużynie.
Dlaczego w świeżym projekcie działa, a u mnie nie?
Skoro ustawienia są tak samo?

Ayene - Pią 15 Paź, 2010 20:29

No to skoro się nie rozumiemy, to zhostuj projekt na ww.mediafire.com (albo innym serwerze) i wyślij mi linka na PW. Zobaczę, o co chodzi.
Tjef - Pon 18 Paź, 2010 15:38

Dobra, dzięki ci, Ayene za pomoc ;-)
Temat do zamknięcia, lub umieście go w SKyrpty VX ;-)


Powered by phpBB modified by Przemo © 2003 phpBB Group