The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Scripting => Topic started by: Atracious on October 08, 2008, 11:38:01 PM

Title: i can't figure out why i'm getting this error....
Post by: Atracious on October 08, 2008, 11:38:01 PM
i have a window with the following code:
[spoiler]class Test_Menu_7 < Window_Base
  def initialize
    super(0, 0, 190, 80)
    refresh
  end
  def refresh
    for i in 0...3
      x = i*40
      y = i
      actor = $game_party.actors[i]
      draw_actor_graphic(actor, x, y)
    end
  end
end
[/spoiler]
and i keep getting this error:

Script 'Window_Base' line 113: NoMethodError occured.
undefined method 'blt' for nil:NilClass

the error is pointing to:
[spoiler]  #--------------------------------------------------------------------------
  # * Draw Graphic
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_actor_graphic(actor, x, y)
    bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
    cw = bitmap.width / 4
    ch = bitmap.height / 4
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
  end
[/spoiler]

any ideas?
Title: Re: i can't figure out why i'm getting this error....
Post by: Falcon on October 09, 2008, 12:38:36 AM
Are you sure there are four party members in the party when you run the code?
Title: Re: i can't figure out why i'm getting this error....
Post by: Atracious on October 09, 2008, 01:29:44 AM
yes there is, i'm just using the defaults, so i have Aluxes, Basil, Gloria, and Hilda.
Title: Re: i can't figure out why i'm getting this error....
Post by: modern algebra on October 09, 2008, 02:32:54 AM
You haven't defined self.contents.

Write this in initialize between super and refresh:

self.contents = Bitmap.new (width - 32, height - 32)
Title: Re: i can't figure out why i'm getting this error....
Post by: Atracious on October 09, 2008, 04:14:31 AM
duuur...i hate it when i miss the little things! :-\
thanks!