The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Scripting => Topic started by: &&&&&&&&&&&&& on April 25, 2013, 07:17:11 AM

Title: (RMVXA) Scene_Menu show Playtime
Post by: &&&&&&&&&&&&& on April 25, 2013, 07:17:11 AM
Hello.
So far with my editing of scripts, I've followed a simple plan-
1. Make changes/Add stuff
2. Get error message
3. Figure out why I got said error message
4. Fix it (A lot of the time, I go back to 2 at this point. Eventually I move on to 5)
5. Refine script

This time however... I'm getting no such error message... so I don't know what I'm doing wrong.

I added this to Scene_Menu.

  def create_playtime_window
    @playtime_window = Window_Playtime.new
    @playtime_window.x = 384
    @playtime_window.y = 272
  end


Then I added this little copy pasted and edited script -

#==============================================================================
# ** Window_Playtime
#------------------------------------------------------------------------------
#  This window displays the party's playtime.
#==============================================================================

class Window_Playtime < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, window_width, fitting_height(1))
    refresh
  end
  #--------------------------------------------------------------------------
  # * Get Window Width
  #--------------------------------------------------------------------------
  def window_width
    return 160
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    contents.clear

  end
  #--------------------------------------------------------------------------
  # * Draw Play Time
  #--------------------------------------------------------------------------
  def draw_playtime(x, y, width, align)
    draw_currency_value(value, currency_unit, 4, 0, contents.width - 8)
    header = DataManager.load_header(@file_index)
    return unless header
  end
  #--------------------------------------------------------------------------
  # * Get Party Playtime
  #--------------------------------------------------------------------------
  def value
    $game_timer
  end
  #--------------------------------------------------------------------------
  # Get Currency Unit
  #--------------------------------------------------------------------------
  def currency_unit
    Vocab::playtime_unit
  end
  #--------------------------------------------------------------------------
  # * Open Window
  #--------------------------------------------------------------------------
  def open
    refresh
    super
  end
end


When I run the game and open the menus... it's just an empty window. Idk wut i did rong

[spoiler](https://rmrk.net/proxy.php?request=http%3A%2F%2Fi109.photobucket.com%2Falbums%2Fn52%2Fdreamslayer7%2FHayashibiaraayashibiara_zpsf1591239.png&hash=f6b6b054c42532dc25df9bbc18625e4036c2d280) (http://s109.photobucket.com/user/dreamslayer7/media/Hayashibiaraayashibiara_zpsf1591239.png.html)[/spoiler]

maybe u no wut is rong w/it
Title: Re: (RMVXA) Scene_Menu show Playtime
Post by: D&P3 on April 25, 2013, 07:40:28 AM
it's your refresh method.
You're telling it to clear the window, but not to draw anything afterwards which leaves it empty. :)
Title: Re: (RMVXA) Scene_Menu show Playtime
Post by: &&&&&&&&&&&&& on April 25, 2013, 10:54:03 AM
Times like this make me wonder, what the hell am I even doing here?
I don't know what I'm doing. I'm not a scientician.

Anyway, this is what I have... and it's still not doing anything. ;___;

I think this is the point where I put the keyboard down and walk away.

#==============================================================================
# ** Window_Playtime
#------------------------------------------------------------------------------
#  This window displays the party's playtime.
#==============================================================================

class Window_Playtime < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, window_width, fitting_height(1))
    refresh
  end
  #--------------------------------------------------------------------------
  # * Get Window Width
  #--------------------------------------------------------------------------
  def window_width
    return 160
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
    def refresh
    contents.clear
    change_color(normal_color)
    draw_playtime(0, contents.height - line_height, contents.width - 4, 2)
  end
  #--------------------------------------------------------------------------
  # * Draw Play Time
  #--------------------------------------------------------------------------
  def draw_playtime(x, y, width, align)
    header = DataManager.load_header(@file_index)
    return unless header
    draw_text(x, y, width, line_height, header[:playtime_s], 2)
  end
  #--------------------------------------------------------------------------
  # * Get Party Playtime
  #--------------------------------------------------------------------------
  def value
    $game_timer
  end
  #--------------------------------------------------------------------------
  # Get Currency Unit
  #--------------------------------------------------------------------------
  def play_time
    Vocab::playtime_unit
  end
  #--------------------------------------------------------------------------
  # * Open Window
  #--------------------------------------------------------------------------
  def open
    refresh
    super
  end
end
Title: Re: (RMVXA) Scene_Menu show Playtime
Post by: D&P3 on April 25, 2013, 12:56:02 PM
Well, just a guess but I believe the issue is caused with your draw_playtime method.
You tell it not to draw anything when there is no header.
You should have it draw something if that's not the case regardless.


  #--------------------------------------------------------------------------
  # * Draw Play Time
  #--------------------------------------------------------------------------
  def draw_playtime(x, y, width, align)
    header = DataManager.load_header(@file_index)
    if header
      draw_text(x, y, width, line_height, header[:playtime_s], 2)
    else
      draw_text(x, y, width, line_height, "Fucked if I know?!", 2)
    end
  end