Page 1 of 1

When making a ZScript status bar, how do you query what the currently-selected inventory hotbar is?

Posted: Sun Nov 06, 2022 5:19 pm
by Chaosvolt
So, I'm working on an update for Shotgunnery mod, and I've rigged an item that's toggled on an off instead of being consumed like a normal invbar powerup. I wanted to have it so, when this toggleable powerup is the one currently selected, its icon changes either depending on if it's on, or possibly depending on if you have any charges of it available. Either way, I figured the logical way to do that, since I don't see any way to modify Inventory.Icon mid-game, would be for the part of the statusbar that shows the current inventory item to only display its normal item if some other item is currently selected.

Then, if the toggleable powerup is the one currently selected, have it then display one of two different images depending on the chosen criteria. I'd also be able to use this if statement so that it shows the amount of charges where the powerup's quantity would normally go.

I see this in the status bar I'm using:
CPlayer.mo.InvSel != null

However, I have yet to figure out how to use this to ask if the current selection is a specific item. What would I need to do to actually get a check for whether CPlayer.mo.InvSel it a specifc desired item?

Re: When making a ZScript status bar, how do you query what the currently-selected inventory hotbar is?

Posted: Mon Nov 07, 2022 12:50 am
by Player701
Suppose your specific desired item is called MyItem. Then, if you do not want to include its subclasses, use the following code:

Code: Select all

let invSel = CPlayer.mo.InvSel;
if (invSel != null && invSel.GetClassName() == 'MyItem')
{
    // TODO: Do something...
}
If you do want to include subclasses, use the following code instead:

Code: Select all

if (CPlayer.mo.InvSel is 'MyItem')
{
    // TODO: Do something...
}

Re: When making a ZScript status bar, how do you query what the currently-selected inventory hotbar is?

Posted: Mon Nov 07, 2022 10:39 am
by Chaosvolt
Ah, thanks. Works just fine. I'd figured it was likely something appended to invSel, like how another check asks for invSel.amount, but my first guesses were invSel.ID and invsel.Name.

Where do you even find out any of this anyway? This is like the third or so question I've run into that boils down to not having the faintest idea where any of the ZScript status bar stuff is documented.

Re: When making a ZScript status bar, how do you query what the currently-selected inventory hotbar is?

Posted: Mon Nov 07, 2022 11:08 am
by Jarewill
Chaosvolt wrote: Sun Nov 06, 2022 5:19 pm since I don't see any way to modify Inventory.Icon mid-game
While the question was already answered, I just wanted to add that it is possible to change the icon mid-game using TexMan:

Code: Select all

Icon = TexMan.CheckForTexture("TNT1A0", TexMan.Type_Sprite);
// "TNT1A0" is the graphic you want to replace with
// Type_Sprite is the type of the graphic you want to use, if unsure just skip the argument or use Type_Any
Chaosvolt wrote: Mon Nov 07, 2022 10:39 am Where do you even find out any of this anyway? This is like the third or so question I've run into that boils down to not having the faintest idea where any of the ZScript status bar stuff is documented.
I usually dig through the default status bars in gzdoom.pk3/zscript/ui/statusbar or the core class in gzdoom.pk3/zscript/engine/ui/statusbar

Re: When making a ZScript status bar, how do you query what the currently-selected inventory hotbar is?

Posted: Mon Nov 07, 2022 11:10 am
by Chaosvolt
Nice, I recall looking for it a while back but failing to find it, my guess is probably didn't check the right folder.