Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
  • 0
Tomo2000

A really stupid scripting question..

Question

Okay, so, I've been trying to get a window to display the currently equipped weapon icon. I managed to get it to show me the one from the database, but not when it changes, and I can't seem to get around it. Currently the code looks like this;

 

@weapon = $data_weapons[$game_party.actors[0].weapon_id].icon_name
bitmap1 = RPG::Cache.icon(@weapon)
rect1 = Rect.new(1, 1, 24, 24)
self.contents.blt(20, 20, bitmap1, rect1, 255)

 

And, note, I thought maybe changing it from $data to $game might fix it, but I got another error;

NoMethodError occurred. undefined method '[]' for nil:NilClass

 

I'm probably missing something really obvious.. Thanks in advance.

~Tomo2000.

Edited by Tomo2000

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

We can't answer your question because, as your describe your problem, it's not a matter of what code you wrote (proof is, it works), but where you put it. Most probably you've put it in some refresh method, which is good, but you have to tell your scene to call this method in order to refresh the window's contents (the point to the refresh method is to be not called on each and every frame, in order to avoid slowdowns). Check if you call this method properly on the appropriate occasion.

 

Note: your Rect should be (0, 0, 24, 24), you'll miss the top row and leftmost column of the picture otherwise.

Share this post


Link to post
Share on other sites
  • 0

Pretty much, it was for a custom menu I just decided to write one night. It's for a window in which displays the actors battler, details, etc.. The window is initiated when the menu first starts up (when escape is pressed), and all the dispose and update lines are in there, so I believe it was called correctly. I tried putting the line into the initialize section of the code, but to no avail (I didn't think it would, but, just in case, since Ruby sometimes likes stuffing around xD ). Anywhere outside of that and, to the extent of my knowledge, it wouldn't recognise the variable. Is there any more help you could provide? Thanks in advance.

Edited by Tomo2000

Share this post


Link to post
Share on other sites
  • 0

It needs placed in the refresh method.

It is convention that a refresh method clears the bitmap and redraws it, so whatever you do in the initialize method, which only gets called once, will be deleted the nanosecond the window contents is drawn.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...