How Do I SBARINFO? - A Tutorial

Handy guides on how to do things, written by users for users.

Moderators: GZDoom Developers, Raze Developers

Forum rules
Please don't start threads here asking for help. This forum is not for requesting guides, only for posting them. If you need help, the Editing forum is for you.
User avatar
Silentdarkness12
Posts: 1555
Joined: Thu Aug 15, 2013 5:34 pm
Location: Plains of Pride

Re: How Do I SBARINFO? - A Tutorial

Post by Silentdarkness12 »

Arookas wrote:You could try to simplify it by not using else/if for the ammo sprite bars and drawing only one sprite per ininventory, like this:

Code: Select all

InInventory HDSecondPistolLoaded, 15 {
  DrawImage "BULLD0",321,88,none,8,8;
}
InInventory HDSecondPistolLoaded, 14 {
  DrawImage "BULLD0",324,88,none,8,8;
}
InInventory HDSecondPistolLoaded, 13 {
  DrawImage "BULLD0",327,88,none,8,8;
}
InInventory HDSecondPistolLoaded, 12 {
  DrawImage "BULLD0",330,88,none,8,8;
}
InInventory HDSecondPistolLoaded, 11 {
  DrawImage "BULLD0",333,88,none,8,8;
}
InInventory HDSecondPistolLoaded, 10 {
  DrawImage "BULLD0",336,88,none,8,8;
}
InInventory HDSecondPistolLoaded, 9 {
  DrawImage "BULLD0",339,88,none,8,8;
}
InInventory HDSecondPistolLoaded, 8 {
  DrawImage "BULLD0",342,88,none,8,8;
}
InInventory HDSecondPistolLoaded, 7 {
  DrawImage "BULLD0",345,88,none,8,8;
}
InInventory HDSecondPistolLoaded, 6 {
  DrawImage "BULLD0",348,88,none,8,8;
}
InInventory HDSecondPistolLoaded, 5 {
  DrawImage "BULLD0",328,95,none,8,8;
}
InInventory HDSecondPistolLoaded, 4 {
  DrawImage "BULLD0",331,95,none,8,8;
}
InInventory HDSecondPistolLoaded, 3 {
  DrawImage "BULLD0",334,95,none,8,8;
}
InInventory HDSecondPistolLoaded, 2 {
  DrawImage "BULLD0",337,95,none,8,8;
}
InInventory HDSecondPistolLoaded, 1 {
  DrawImage "BULLD0",340,95,none,8,8;
}
You could also utilize weapon primary/secondary ammo icons, as well as weapon icons so that you only draw icons for the weapons/ammo in one place. You could then set the offsets of specific icons in their respective graphic files if you need to have the positions differ.
Wouldn't that cause ALL of the ininventory sprites to get drawn? That would sort of mess things up in that regard, wouldn't it?
User avatar
arookas
Posts: 265
Joined: Mon Jan 24, 2011 6:04 pm
Contact:

Re: How Do I SBARINFO? - A Tutorial

Post by arookas »

No. The idea would be that since ininventory does equal to or larger than, you'd draw one icon per check. Going on the assumption that if you have at least, say 5 rounds loaded, the fifth bullet icon should be drawn. This is done for each number. Without the else's, the ininventories work independently instead of chaining and drawing the entire bar at that state in each block.
User avatar
Tapwave
Posts: 2096
Joined: Sat Aug 20, 2011 8:54 am
Preferred Pronouns: No Preference
Graphics Processor: nVidia with Vulkan support

Re: How Do I SBARINFO? - A Tutorial

Post by Tapwave »

Silentdarkness12 wrote: Wouldn't that cause ALL of the ininventory sprites to get drawn? That would sort of mess things up in that regard, wouldn't it?
Put an "else" before every InInventory check after the first. That's how I made prestige icons work in my own mod. If all those graphics pile up like in Black & Grey, then you don't need the elses, as it'll only draw the sprites if you have X or more of the InInventory item.
User avatar
Silentdarkness12
Posts: 1555
Joined: Thu Aug 15, 2013 5:34 pm
Location: Plains of Pride

Re: How Do I SBARINFO? - A Tutorial

Post by Silentdarkness12 »

Tapwave wrote:
Silentdarkness12 wrote: Wouldn't that cause ALL of the ininventory sprites to get drawn? That would sort of mess things up in that regard, wouldn't it?
Put an "else" before every InInventory check after the first. That's how I made prestige icons work in my own mod. If all those graphics pile up like in Black & Grey, then you don't need the elses, as it'll only draw the sprites if you have X or more of the InInventory item.
Here's the thing though. It's not just one else. What if I need to do an else to the second one? And a third?

And so on and so forth. I'm trying to think this through logically, and i'm not seeing it. An example, please?
User avatar
Tapwave
Posts: 2096
Joined: Sat Aug 20, 2011 8:54 am
Preferred Pronouns: No Preference
Graphics Processor: nVidia with Vulkan support

Re: How Do I SBARINFO? - A Tutorial

Post by Tapwave »

Sure! Here is the code I use in FragTrak to display the prestige medals. It'll only display the top level one you own.
Spoiler:
The WeaponPrestige items are given via ACS after checking a CVAR, if you're wondering.
User avatar
Silentdarkness12
Posts: 1555
Joined: Thu Aug 15, 2013 5:34 pm
Location: Plains of Pride

Re: How Do I SBARINFO? - A Tutorial

Post by Silentdarkness12 »

It's me again.

The rest of the forum: dear god why doesn't he just go away


So i'm trying to make a bar to measure the airburst time on the grenade launchers and such in Hideous Destructor. However, I don't want a background image for the bar, and no matter what I do, whether it's putting in nullimage, a null TEXTURE or TNT1A0, a blacked out version of the bar appears in the extreme upper left corner of the screen, seemingly independent of the X and Y coordinates. What am I doing wrong here?

Code: Select all

InInventory AirburstCount,1
{
DrawImage "BPSIA0",30,190,center,40,40;
DrawBar "AIRBA0","null",AirburstCount,horizontal,interpolate(3),90,150;
}
else
{
DrawImage "BPSIB0",30,190,center,40,40;
}
User avatar
wildweasel
Posts: 21706
Joined: Tue Jul 15, 2003 7:33 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): A lot of them
Graphics Processor: Not Listed
Contact:

Re: How Do I SBARINFO? - A Tutorial

Post by wildweasel »

Your back image must have the same dimensions as the front image. Try creating a Textures entry with no patches, with a canvas size equal to the size of the front image.
User avatar
Silentdarkness12
Posts: 1555
Joined: Thu Aug 15, 2013 5:34 pm
Location: Plains of Pride

Re: How Do I SBARINFO? - A Tutorial

Post by Silentdarkness12 »

wildweasel wrote:Your back image must have the same dimensions as the front image. Try creating a Textures entry with no patches, with a canvas size equal to the size of the front image.
Already did that. No luck. It's still there. Also tried unchecking 'null texture'. Also no good.
User avatar
Tapwave
Posts: 2096
Joined: Sat Aug 20, 2011 8:54 am
Preferred Pronouns: No Preference
Graphics Processor: nVidia with Vulkan support

Re: How Do I SBARINFO? - A Tutorial

Post by Tapwave »

Silentdarkness12 wrote: Already did that. No luck. It's still there. Also tried unchecking 'null texture'. Also no good.
Have you tried taking the image you used to make your full bar, make it completely blank, then give it the same offsets? Normally the TEXTURES thing should do exactly that, but it shouldn't hurt to try.
User avatar
Silentdarkness12
Posts: 1555
Joined: Thu Aug 15, 2013 5:34 pm
Location: Plains of Pride

Re: How Do I SBARINFO? - A Tutorial

Post by Silentdarkness12 »

Tapwave wrote:
Silentdarkness12 wrote: Already did that. No luck. It's still there. Also tried unchecking 'null texture'. Also no good.
Have you tried taking the image you used to make your full bar, make it completely blank, then give it the same offsets? Normally the TEXTURES thing should do exactly that, but it shouldn't hurt to try.
Yes, I already tried that too.
artagon96
Posts: 20
Joined: Wed Apr 05, 2017 2:54 pm

Re: How Do I SBARINFO? - A Tutorial

Post by artagon96 »

hey guys i want to know how to make status bar not showable when armor is depleted can someone help me with this
User avatar
wildweasel
Posts: 21706
Joined: Tue Jul 15, 2003 7:33 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): A lot of them
Graphics Processor: Not Listed
Contact:

Re: How Do I SBARINFO? - A Tutorial

Post by wildweasel »

artagon96 wrote:hey guys i want to know how to make status bar not showable when armor is depleted can someone help me with this
There's probably a more elegant way to do this now, but you'd do this by enclosing all the relevant parts of your status bar in an InInventory block. For example, this would show only if you had GreenArmor in your inventory:

Code: Select all

statusbar normal
{
   InInventory GreenArmor
   {
      [...]
   }
}
artagon96
Posts: 20
Joined: Wed Apr 05, 2017 2:54 pm

Re: How Do I SBARINFO? - A Tutorial

Post by artagon96 »

Yes, it works, and now I need some help so you can change the status bar between two types of grenades when equipped with an assault rifle with a grenade launcher the grenade status bar changes to grenade ammunition and when I change the weapon it again goes back to the previous statusbar

PS: sorry for my bad english
User avatar
olzhas1one
Posts: 70
Joined: Sun Feb 26, 2017 6:29 am

Re: How Do I SBARINFO? - A Tutorial

Post by olzhas1one »

Thank you so much. Finally placed health and ammo on the places I wanted and managed to add scores
User avatar
Major Cooke
Posts: 8170
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: How Do I SBARINFO? - A Tutorial

Post by Major Cooke »

...I really need to write a tutorial on how to make 'zbarinfo' soon.

I mean, I can start making one but there's still things left unexplored.

But to give me a good refresher course, Weasel, you could point me to a mod of yours that I can convert for you and document along the way, which will be the perfect instrument for writing a tutorial down.
Unless someone beat met to the chase already.

Oh and, if you want some extra nifty features that have been floating in your head yet you couldn't do it with sbarinfo, do tell. :mrgreen:

I'll start off with a straight conversion, one to one, and then I'll add those extra ideas.
Post Reply

Return to “Tutorials”