Active inventory Item in a window

Started by jamesreg, Mon 21/09/2009 23:18:28

Previous topic - Next topic

jamesreg

How would I go about taking the currently active inventory item and be able to display it in a seperate small window like next to a character portrait or something like that and have it change anytime you change the active inventory item.

Matti

Make A GUI or character and change its spriteslot/view according to the active inventory item.

lsb

i believe it's (INVSHR) for that, isn't it?

Khris

#3
INVSHR...?

Code: ags
// above rep_ex
InventoryItem*oai;  // old active inv

// inside rep_ex
  if (player.ActiveInventory != oai) {   // only change when necessary, not every game loop
    oai = player.ActiveInventory;
    if (oai == null) bAI.NormalGraphic = 0; // remove button image
    else bAI.NormalGraphic = bAI.Graphic;  // set button image to active inv item's sprite
  }


(Assuming there's a non-clickable GUI with a button called "bAI" used to display the inv item.
If the button will still react to mouse hovering / clicking [I haven't tested this], changing the GUI's .BackgroundGraphic instead might be a better idea.)

Edit: Aha! Never seen this before, hehe

Quote from: manualThe default option is the Sierra-style pop-up inventory window, which is popped up by clicking on the Inventory icon on the icon bar. You can also have the current inventory item displayed in its own button on the icon bar by creating a button on the GUI and setting its text to (INV) which stretches the item picture to the button size, or (INVNS) which draws the inventory item picture straight onto the button with no resizing. Finally, (INVSHR) , probably the best option, will draw it at actual size if it will fit, or shrink it if not.

SMF spam blocked by CleanTalk