Display inventory quantity in inventory?

Started by zabnat, Wed 23/07/2008 02:05:35

Previous topic - Next topic

zabnat

When "Display multiple icons for multiple items" is false and you have multiple same items in your inventory: is it possible to display the number of those items next to items icon?
I saw this done in one RoN game, but I'm not sure if they cheated or not.

Ishmael

Create labels at the positions where you want to have the quantities and set those labels to show the amount of the specific inventory index.
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Khris

Or print the amount on a DynamicSprite holding the InvItem's .Graphic and set that to the .Graphic (while storing the original slot # in an array).
I've actually written a module that does that for Bernard's Room, but it wouldn't work with the current version of AGS.
Maybe I'll get around to updating it und putting it here.

Michigami

Quote from: Ishmael on Thu 24/07/2008 00:08:40
Create labels at the positions where you want to have the quantities and set those labels to show the amount of the specific inventory index.

how would one go about that anyway?  i've had zero luck getting labels to work, and have been trying to do the same thing.

Khris

http://www.2dadventure.com/ags/InvAmount.scm.doc

Download, remove .doc, import it.

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

Must be called in game_start.
Font used to display amount, background color of Inventory Window, used InvWindow (e.g. the default is invCustomInv).

InvAmount.SetGraphic(InventoryItem*item, int slot);

Used to change the current inventory item's graphic used by the module.
I used this to move the graphic slightly to the left while a number was displayed in the bottom right.

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


Character who gains/loses amount items.
LoseInv handles amounts above current possession.

NOTE: Currently, the module doesn't display "1" if the player has just one item.

Shockbolt

Quote from: KhrisMUC on Thu 26/02/2009 09:53:40
http://www.2dadventure.com/ags/InvAmount.scm.doc

Download, remove .doc, import it.

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

Must be called in game_start.
Font used to display amount, background color of Inventory Window, used InvWindow (e.g. the default is invCustomInv).

InvAmount.SetGraphic(InventoryItem*item, int slot);

Used to change the current inventory item's graphic used by the module.
I used this to move the graphic slightly to the left while a number was displayed in the bottom right.

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


Character who gains/loses amount items.
LoseInv handles amounts above current possession.

NOTE: Currently, the module doesn't display "1" if the player has just one item.


Downloaded script, imported into scripts section and added the codes You suggested above, but still I get an error message when I try to test the game:

GlobalScript.asc(54): Error (line 54): static non-property access: internal error


Here You see the codes I have now:

// Called when the game starts, before the first room is loaded
function game_start() {   

  InvAmount.Init(int font, int invGUI_bg, InvWindow*InvWin);
  InvAmount.SetGraphic(InventoryItem*item, int slot);
  InvAmount.AddInv(Character*who, InventoryItem*item, int amount);
  InvAmount.LoseInv(Character*who, InventoryItem*item, int amount);

  // Put the code all in a function and then just call the function.
  // It saves cluttering up places like game_start.
  initialize_control_panel();
  // Use the KeyboardMovement module to, per default, replicate the standard
  // keyboard movement of most Sierra games. See KeyboardMovement.txt for more info
KeyboardMovement.SetMode(eKeyboardMovement_Tapping);

Khris

You have to call InvAmount.Init() with the actual parameters, like I described, e.g.:

Code: ags
  InvAmount.Init(1, 0, MyInv);


Then call InvAmount.AddInv / .LoseInv to make a char get / lose inv items (not in game_start, except a char is supposed to start out with multiple items).

SMF spam blocked by CleanTalk