The RPG Maker Resource Kit

Other Game Creation => Program Troubleshooting => Topic started by: Wiimeiser on April 22, 2013, 12:02:39 PM

Title: VXA picture script bug?
Post by: Wiimeiser on April 22, 2013, 12:02:39 PM
Whenever I delete a picture with a center origin, I get an error on this line:

Quote
      self.ox = bitmap.width / 2


It's a bug in the script itself, I tried in a vanilla project.

EDIT: I think I know what's probably causing it; it doesn't actually clear the image from memory, it just replaces it with a blank 0x0 bitmap and applies the settings, so it ends up trying to divide a null. This also explains the issue with lag.
Title: Re: VXA picture script bug?
Post by: &&&&&&&&&&&&& on April 22, 2013, 08:48:31 PM
Which script? It's kinda hard to help if we don't know what script you're talking about.
Title: Re: VXA picture script bug?
Post by: LoganF on April 22, 2013, 09:47:25 PM
Vanilla project means that no custom scripts are being used, so it's definitely a default script, and probably Sprite_Picture.

That is best guess, however.

Whenever I delete a picture with a center origin, I get an error on this line:

Quote
      self.ox = bitmap.width / 2


It's a bug in the script itself, I tried in a vanilla project.

EDIT: I think I know what's probably causing it; it doesn't actually clear the image from memory, it just replaces it with a blank 0x0 bitmap and applies the settings, so it ends up trying to divide a null. This also explains the issue with lag.

But it's not a divide by 0, it's divide by 2, so a bitmap of width 0 would result in self.ox = 0 /2 = 0.

It would do good to know:

What the error type is, and what it is you are doing to delete a picture. Are you talking about through an event command (Erase Picture, for example) or through code (either a script or the Script Command)? Knowing that might help work it out. I'm unable to cause an error, but seeing as I know nothing about how to cause it it's hard to know if I am doing the same thing.

You could send the project you have that has the error.
Title: Re: VXA picture script bug?
Post by: Wiimeiser on April 22, 2013, 10:57:06 PM
It's a bug in a default script, what it seems to be trying to do is halve a number that doesn't exist when it erases a picture that isn't at source 0 or is centered, as far as I can tell. So what it's doing is carrying over settings for a picture that doesn't exist and AFAIK it tries to divide nothing (not even zero?) in half
Title: Re: VXA picture script bug?
Post by: LoganF on April 23, 2013, 12:07:53 AM
I can't recreate the bug/error without some exact information or just a copy of the project folder that has the bug in place.

If the bitmap variable is nil, you should get an "undefined method 'width' for nil:NilClass" error.
Title: Re: VXA picture script bug?
Post by: modern algebra on April 23, 2013, 01:38:16 AM
Hmm, judging by what you've said and looking at Sprite_Picture and assuming that the error is a NilError, I could see it occurring in two situations:

(1) You show a picture through an event command with Centre origin, but don't set any actual graphic to be shown. That would cause the error since origin would be 1 but the picture name would be empty. In that case, the error would occur immediately upon trying to show the picture, not at the time it is erased.

(2) You use a script call to clear the name of a picture without changing the origin to 0.

If you are using the default erase method for Game_Picture, then there shouldn't be an occasion where the picture name is empty but the origin is 1. Both are deleted in the same method, so I can't see why this error would occur when you erase the picture through an event command.

So I guess I have this question:

(1) Is it possible that you are not setting a graphic when you use the Show Picture command?

And I also have Logan's questions too:

(2) Are you using events or scripts to call and erase the picture?
(3) What does the error message say?
(4) Will you upload a demo with the error?
Title: Re: VXA picture script bug?
Post by: Wiimeiser on April 23, 2013, 07:03:35 AM
It happens when I erase a picture, check the event in the project. Sorry for the unusual choice of picture, since there's nothing in the Pictures folder by default I just grabbed the first thing I could(Yes, that's actually in my main project's Pictures folder for no given reason)
Title: Re: VXA picture script bug?
Post by: LoganF on April 23, 2013, 07:53:07 AM
It's actually a bug/problem with your version of the scripts data and not VXA in general.

In my version of Game_Picture, I have the following code:

Code: [Select]
  def erase
    @name = ""
    @origin = 0
  end

In your version, that same method:

Code: [Select]
  def erase
    @name = ""
  end

For whatever reason, you are missing a line there.

What this means is that the @origin variable is not set to 0 when a picture is erased. This causes this code to pass incorrectly:

Code: [Select]
  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

The "if" check fails, which leads to the "else" case being processed. Then, it tries to call width on the bitmap object, but because it is a nil value, it is unable to call the method and you get the NoMethodError that you are seeing.

What you need to do then, is open up the Game_Picture script, go to line 116 and add in the missing line:

Code: [Select]
@origin = 0

and your issue will be fixed.

I'm not sure why your version of the script data is incorrect but it will cause that bug to be present in any new project that you create.
Title: Re: VXA picture script bug?
Post by: Wiimeiser on April 23, 2013, 11:12:39 AM
Thanks, I think it's broken because I got the Preorder version...