Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Display Number in HUD [RESOLVED]

What's the coding for a picture and a number to appear corresponding to the number of an item in an inventory? The ID of the item and the coordinates on-screen should be easy to modify.
Okay, I'm having trouble with adding switches. Also, what's the code to show an icon? And how do I make it add an icon each time a certain switch is turned on?

How do I make the window appear/disappear for cutscenes? The $scene.my_window.appear/disappear still seems to have some bugs.
When I first turn the switch on (to make the HUD visible), it doesn't appear unless I use "$scene.my_window.appear". However, when I do that, there are no numbers. I have to make it disappear, then appear again to get them to appear. Also, when I go into my menu (or somewhere other than Scene_Map) and come back, it disappears! Here's the full script in case it helps. Thanks if you can help solve this.
 
well the spoiler didn't show anything... I wonder why did that happen...
you could take a look at the Window_Item script to see how you can display an specific item and the current quantity / amount / or anything else.
about the switch I may say it's the most simple thing you requested here.
just use $game_switches[n] = true or false
n is a number.
then you might include a conditional branch like this:
if $game_switches[n] == true
  # include here the lines that will display the item
elsif $game_switches[n+1] == true
  # include here the lines that will display the next item
elsif $game_switches[n+2] == true
  # include here the lines that will display the next item
  # repeat this steps as much as you want...
end
n+1 and n+2 mean that you may enter the next number:
n = 1  then n+1 = 2 and so on.
 
They're basically the keyboard keys you press to use the item, you don't have to worry about that, I can do all that with events. All I need is the number of the item in the inventory so you can keep track of how many you can use...
 
mmm it would be better to include the keys you may need to press in the script... by the way, there is a way to change the item displayed on screen without setting more than a single key to be able to change it...
 
No, the items are pre-set in my game. Each key (A S D) only corresponds to one item. All the item stuff I can probably figure out myself, you don't really need to worry about that part. All I need is for a number to display over A, S, and D when the corresponding switch is on, depending on how many of item (ex) 1, 2, 3 are in the inventory.

EDIT: I edited the first post, check it for some examples if it's still unclear.
 
Bump.. all I need to know is how to make a number appear corresponding to the number of an item in your inventory. If someone could just help me with that code, I can position the coordinates myself.
 
well, I may say now that I developed a "not so efficient" script that let's a player see how much items they have, in this specific case it shows the potions, perfumes, tonics and the antidotes you have.
if you don't have any of those items it won't show anything, even if you own several seeds of intelligence or anything else. you're still able to see how the numbers change their color depending on how much items you already possess. that's working fine.
if you're interested, just pm me.
regimos, I never wanted to send you such an easy script.
 
Well actually there's no need for an image, I edited it.
Originally I put the image so someone could space out the x and y coordinates for me, but to make it easier for request takers I took it out. All I need to know is the coding to make a number appear on-screen depending on the items in the inventory, with ID and the x and y coordinates customizable, thanks.
 
The command is:
Code:
$game_party.item_number(item_id)

So in order to draw the number on screen you could use:
Code:
self.contents.draw_text(x, y, width, height, $game_party.item_number(item_id).to_s, alignment)

An item_id of 1 will draw the amount of 'Potions' the party has, and so on and so forth.
 
EDIT: A few questions, as I've still got a lot to learn about RGSS :-\

1. Where would I put this? A call script gives it an error. I just want to know how I can implement it to show if a switch is on.
2. How would I delete the text?
3. What does alignment mean/do?

Thanks a lot...
 
Regimos":27cde39z said:
EDIT: A few questions, as I've still got a lot to learn about RGSS :-\

1. Where would I put this? A call script gives it an error. I just want to know how I can implement it to show if a switch is on.
2. How would I delete the text?
3. What does alignment mean/do?

Thanks a lot...

1. You place this in your HUD Window which is called from Scene_Map. You can only use .draw_text on windows.
2. You can delete the text by disposing the window that it is drawn on. (Or making the window invisible)
3. Alignment aligns the text. 0 is the left, 1 is the middle and 2 is to the right. It is optional, so if you do not want to use it, you don't have to.

I suggest you read ccoa's tutorial on Windows (Lesson 2 explains how to incorporate a window into a scene, which is needed to use the .draw_text command.) Her tutorial can be found HERE. The tutorial explains each line of a window in easy to understand language. Feel free to PM me if you want any additional information.

Cheers,

Syn.
 
Well, thanks for the info, but my "HUD" is actually a picture (I think it looks better than a bland window, since I can put in icons and everything)  :P That's why I just want the number to appear, not anything else, so it'll go right over the image. Is there a way to show just a number, and no window or anything?

Thanks!
 
You can put your image inside the window and then write what you want with draw_text, believe me, it's easy.

Code:
class Scene_Map
  alias main_gold main
  def main
    #GOLD WINDOW
    @gold_window = Window_Gold.new
    @gold_window.x = 480
    @gold_window.y = 0
    @gold_window.opacity=0
    @gold_window_bg = Sprite.new
    @gold_window_bg.bitmap = RPG::Cache.picture("gold-window-bg")
    @gold_window_bg.x=480
    @gold_window_bg.visible=true
    @gold_window_bg.z=101
    @gold_window.contents.font.size=14
    @gold_window.refresh
    #original call
    main_gold
    @gold_window.dispose
    @gold_window_bg.dispose
  end
  #-----------------------------------------------------------------------------
  alias update_gold update
  def update
    # Refresh gold window
    @gold_window.refresh
    update_gold
  end
end

 

This code, for example, makes the Gold window appear on the map. opacity 0 makes the windowskin invisible and @gold_window_bg is the picture that's actually displayed.

http://img220.imageshack.us/img220/9815/immaginejl7.th.jpg[/img]

See? Everything but "0 Guil" is a picture.
 
Regimos":l0ma6nvi said:
Well, thanks for the info, but my "HUD" is actually a picture (I think it looks better than a bland window, since I can put in icons and everything)  :P That's why I just want the number to appear, not anything else, so it'll go right over the image. Is there a way to show just a number, and no window or anything?

Thanks!

Yup, Charlie Lee beat me to it. You can draw a picture on your window, then draw your text on that picture and finally make the window invisible. So all you have on your HUD is your picture with the text you want to draw.
 
EDIT: Still not sure how exactly to do it  :-\ I know basic coding and things for RGSS, but I just can't combine it into a script. Could anyone help write a short script for me with comments so I can learn how it's to be done? I just want a window to appear in the upper-left corner, show a picture, and show a number. I can probably tweak an already-existing script easier.

Btw... Synthesize, your link to ccoa's tutorial isn't working. There's an IPS driver error or something like that.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top