Suggestion: Display inventory item amount on inventory item

Started by Nine Toes, Mon 25/06/2007 09:01:26

Previous topic - Next topic

Nine Toes

I'd like to suggest the ability to display the amount that you have of a given inventory item on top of the item when it's in an inventory (a-la Morrowind, or the older Resident Evil games).

See, AGS already has the ability to display multiple inventory items multiple times, or, if you leave the option box unchecked, you will only see that you have one of that given item, even though you may have two or more of it.  It just seems logical to have this option if someone decides that they don't want 14 of the same item cluttering up their inventory, but they still want to know how many there is.

On the other hand, is there a way to do this already, such as a module, or a script that someone wrote?  I've been playing around with it, using a label and an integer, but I've been having to come up with ways to make the label move with the item's graphic every time a new, different item is added to the inventory.  I'm just looking for a way to save myself an obvious ton of scripting.

EDIT:
Okay.  Now that I've thought about it some more, I could just have a stationary label outside of the actual inventory window itself, and whenever I select an item, I could have AGS set the label's text to the amount of the active inventory item.

BUT... I still say it's a sound idea to have the option to display the amount of the item in some manner if you don't have that box checked.

Let me know what you think.
Watch, I just killed this topic...

Khris

I've started writing a module that uses DynamicSprites do display the amount on top of the item.
In theory, it works, but in the inventory GUI, all items are displayed as blue cups.

A simple test was to put these lines in the first rooms after fadein:
Code: ags
  player.AddInventory(iKey);
  DynamicSprite*d=DynamicSprite.CreateFromBackground(GetBackgroundFrame(), 100, 100, 30, 15);
  iKey.Graphic=d.Graphic;

And again, blue cup.

It seems a bit strange that it isn't possible to set an InventoryItem's Graphic to a DynamicSprite's Graphic.
Am I missing something?

Ashen

Don't declare the DynamicSprite in 'after fadein'? As I understand it, once the function they're declared in finishes, they're deleted from memory (right?), so the Item would revert to the default 'no graphic' graphic, the Blue Cup o' doom.

EDIT:
Tried it with d declared elsewhere, and it works fine.
I know what you're thinking ... Don't think that.

Khris

Yeah, I feel stupid.
I declared an array outside any function and then didn't use it... :P

InvAmount 0.1

InvAmount.Init(int font, int invGUI_bg, InvWindow*InvWin);

must be called in game_start to set the font to use, the background color of the inv GUI and the inv window the player uses.
(Default game example: InvAmount.Init(1, 7, invCustomInv);)

The module uses on_event to update the player's inventory if player.AddInventory or player.LoseInventory are called.

Additional commands:

InvAmount.AddInv(Character*who, InventoryItem*item, int amount);
InvAmount.LoseInv(Character*who, InventoryItem*item, int amount);


Should be self-explanatory. Add amount of item to who's inventory.

Edit: good idea, function names updated, modified version online

strazer

Good work I'm sure, but may I suggest renaming the struct from "IA" to "InvAmount" to reduce the probability of it clashing with other modules?

SMF spam blocked by CleanTalk