Jump to content
DorFenn

Write variables in Menu

Recommended Posts

Hello everyone!

I have a problem, you see, I am scripting and making adjustments to my menu, and I wanted to draw some variables on the weapons within the inventory, the variable appears, but now it also does with the other weapons. 

I have tried to use derivations such as "If / Elsif", or use it as a "Case" and try with "When" but I have not been able to solve it, the variable continues to appear on all weapons.

Here's the code and a screenshot.

Spoiler

  def draw_item_number(rect, item)
    Font.default_size = 16
    if $game_party.usable?(item)
    draw_text(rect, sprintf(" %2d", $game_party.item_number(item)), 0)
  elsif $data_weapons[1] 
    draw_text(rect, sprintf(" %2d", $game_variables[12]), 0) # PISTOL
    end
end

 

I enclosed the value in red and as it is repeated, I have no idea what I am doing wrong.

Captura.PNG.cf251908212a05079d02e82c949bb9fd.PNG

Share this post


Link to post
Share on other sites
Posted (edited)

Try this:

  def draw_item_number(rect, item)
    Font.default_size = 16
    if $game_party.usable?(item)
    draw_text(rect, sprintf(" %2d", $game_party.item_number(item)), 0)
  elsif $data_weapons[1] == item
    draw_text(rect, sprintf(" %2d", $game_variables[12]), 0) # PISTOL
    end
  end
Edited by Kayzee
  • Thanks 1

Share this post


Link to post
Share on other sites
Posted (edited)

Oh my God, Oh my God, Oh my God, it worked perfectly with all three variables!

Captura.PNG.5cbea48c473809be54471c3155c275dc.PNG

Thank you very much Kayzee!

PS: Will you know any method to show images within the menu? o Even some text box

Edited by DorFenn
Pd

Share this post


Link to post
Share on other sites

I am glad to help! *sprinkles fairy dust on you*

And yes I do! Look at Window_Base's draw_icon, draw_face, and draw_character and they all use contents.blt to draw images to the window! You can use it to draw any image you want!

For example:

bitmap = Cache.system("Iconset") # The whole icon set, just as an example, can load any image in graphics/system this way
contents.blt(0, 0, bitmap, bitmap.rect) # Puts it at 0, 0 on the current window

Might take a bit to figure out the details, but it's pretty simple when you do

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted