New account registration is temporarily disabled.

RPG MAKER VX ACE: ERASE PICTURE COMMAND ERROR

Posts

Pages: 1
Alright, so here's my problem, I have had a picture be put on screen, then I used the erase picture command to remove it, sound simple enough? Well, not for me unfortuantly...You see every time I add the erase picture command, this error pops up: Sprite_picture line 54: NoMethodError occured undefined method for 'width' nil:Nilclass. So yeah, if anyone would be kind enough to help me figure out how to fix this, it would be GREATLY appreciated.

EDIT: I FIXED THE PROBLEM! Unfortunately I don't know EXACTLY what happened, but I replaced the "Game_picture" and "Sprite_Picture" scripts with ones from a NEW project I made, my guess is that something accidentally was deleted from the old scripts. My brain is fried after this mess. Thank you for your help guys. You gave me the idea after all.
Marrend
Guardian of the Description Thread
21806
I'm not really sure, but, the scenario in my head is that you had multiple pictures, had already erased at least one of them, and simply forgot the one you're trying to erase was already erased?

That aside, I did a bit of cross-referencing to see what line 54 of Sprite_Picture was at, what method it was in, and what all was supposed to be happening. We're looking at...

class Sprite_Picture < Sprite
  #--------------------------------------------------------------------------
  # * Update Origin
  #--------------------------------------------------------------------------
  def update_origin
    if @picture.origin == 0
      self.ox = 0
      self.oy = 0
    else
      self.ox = bitmap.width / 2 # <-this is line 54
      self.oy = bitmap.height / 2
    end
  end
end


...this function. Perhaps there is interference from...

class Sprite_Picture < Sprite
  #--------------------------------------------------------------------------
  # * Update Transfer Origin Bitmap
  #--------------------------------------------------------------------------
  def update_bitmap
    if @picture.name.empty?
      self.bitmap = nil
    else
      self.bitmap = Cache.picture(@picture.name)
    end
  end
end


...this function, too? I also looked up what the Erase Picture event-command does...

class Game_Interpreter
  #--------------------------------------------------------------------------
  # * Erase Picture
  #--------------------------------------------------------------------------
  def command_235
    screen.pictures[@params[0]].erase
  end
end


...for the sake of reference. I believe the "screen" variable, in that case, is an instance of Game_Screen. Meaning that the function call there would (eventually) call...

class Game_Picture
  #--------------------------------------------------------------------------
  # * Erase Picture
  #--------------------------------------------------------------------------
  def erase
    @name = ""
    @origin = 0
  end
end


...this function?

I dunno. Now that I think on it, even if you pointed to a picture that didn't exist, I feel it would not generate that particular error. If there was an error message regarding that, I would expect more an error about "erase" being an undefined method.
Are you sure it is the Erase Picture command giving you this error and not Move Picture? I have gotten this exact error with the Move Picture command if you try to move a picture that isn't there. i.e.: You have only Picture 1 active, but tried to move Picture 2 instead.
author=Sgt M
Are you sure it is the Erase Picture command giving you this error and not Move Picture? I have gotten this exact error with the Move Picture command if you try to move a picture that isn't there. i.e.: You have only Picture 1 active, but tried to move Picture 2 instead.

I'm sure of it, I tested it out, and sure enough, it was the "Erase Picture" command causing problems
author=Marrend
I'm not really sure, but, the scenario in my head is that you had multiple pictures, had already erased at least one of them, and simply forgot the one you're trying to erase was already erased?

That aside, I did a bit of cross-referencing to see what line 54 of Sprite_Picture was at, what method it was in, and what all was supposed to be happening. We're looking at...

class Sprite_Picture < Sprite
  #--------------------------------------------------------------------------
  # * Update Origin
  #--------------------------------------------------------------------------
  def update_origin
    if @picture.origin == 0
      self.ox = 0
      self.oy = 0
    else
      self.ox = bitmap.width / 2 # <-this is line 54
      self.oy = bitmap.height / 2
    end
  end
end

...this function. Perhaps there is interference from...

class Sprite_Picture < Sprite
  #--------------------------------------------------------------------------
  # * Update Transfer Origin Bitmap
  #--------------------------------------------------------------------------
  def update_bitmap
    if @picture.name.empty?
      self.bitmap = nil
    else
      self.bitmap = Cache.picture(@picture.name)
    end
  end
end

...this function, too? I also looked up what the Erase Picture event-command does...

class Game_Interpreter
  #--------------------------------------------------------------------------
  # * Erase Picture
  #--------------------------------------------------------------------------
  def command_235
    screen.pictures[@params[0]].erase
  end
end

...for the sake of reference. I believe the "screen" variable, in that case, is an instance of Game_Screen. Meaning that the function call there would (eventually) call...

class Game_Picture
  #--------------------------------------------------------------------------
  # * Erase Picture
  #--------------------------------------------------------------------------
  def erase
    @name = ""
    @origin = 0
  end
end

...this function?

I dunno. Now that I think on it, even if you pointed to a picture that didn't exist, I feel it would not generate that particular error. If there was an error message regarding that, I would expect more an error about "erase" being an undefined method.
From the looks of it, it says that width is undefined I suppose, but what would I put in those quotations to fix this?Hmm...
I've been looking all over the internet for this problem, but seemingly coming up short, I can't find really anyone else who encountered this problem, well, except for one guy that had the exact same problem and made a steam post, and another guy commented on it saying: "Add the Missing Script"
So I think we are on to something.
If I can't fix this, me and my team are going to have a major problem, as we are gonna heavily use pictures in our game.

Wait hold on, something doesn't seem right, Marrend, can you send me the full script that you have for rpg maker? I need to check something, I think I don't have the same lines of code that you have.

Marrend
Guardian of the Description Thread
21806
I've just been copy-pasting of scripts from a new project, to be honest. However, if it would help, the entirely of Sprite_Picture looks like...

#==============================================================================
# ** Sprite_Picture
#------------------------------------------------------------------------------
#  This sprite is used to display pictures. It observes an instance of the
# Game_Picture class and automatically changes sprite states.
#==============================================================================

class Sprite_Picture < Sprite
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     picture : Game_Picture
  #--------------------------------------------------------------------------
  def initialize(viewport, picture)
    super(viewport)
    @picture = picture
    update
  end
  #--------------------------------------------------------------------------
  # * Free
  #--------------------------------------------------------------------------
  def dispose
    bitmap.dispose if bitmap
    super
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    update_bitmap
    update_origin
    update_position
    update_zoom
    update_other
  end
  #--------------------------------------------------------------------------
  # * Update Transfer Origin Bitmap
  #--------------------------------------------------------------------------
  def update_bitmap
    if @picture.name.empty?
      self.bitmap = nil
    else
      self.bitmap = Cache.picture(@picture.name)
    end
  end
  #--------------------------------------------------------------------------
  # * Update Origin
  #--------------------------------------------------------------------------
  def update_origin
    if @picture.origin == 0
      self.ox = 0
      self.oy = 0
    else
      self.ox = bitmap.width / 2
      self.oy = bitmap.height / 2
    end
  end
  #--------------------------------------------------------------------------
  # * Update Position
  #--------------------------------------------------------------------------
  def update_position
    self.x = @picture.x
    self.y = @picture.y
    self.z = @picture.number
  end
  #--------------------------------------------------------------------------
  # * Update Zoom Factor
  #--------------------------------------------------------------------------
  def update_zoom
    self.zoom_x = @picture.zoom_x / 100.0
    self.zoom_y = @picture.zoom_y / 100.0
  end
  #--------------------------------------------------------------------------
  # * Update Other
  #--------------------------------------------------------------------------
  def update_other
    self.opacity = @picture.opacity
    self.blend_type = @picture.blend_type
    self.angle = @picture.angle
    self.tone.set(@picture.tone)
  end
end

...this to me.

*Edit: Not even sure if it's relevant, but, my version of Ace is 1.02a. I may have initially obtained Ace during the VX Ace Nugget Crash Course, but, this particular version I got when I moved to my current laptop in... uh... 2015?
Pages: 1