Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: bx83 on Thu 01/06/2017 08:46:59

Title: Scrolling automatically to top or bottom of inventory icons
Post by: bx83 on Thu 01/06/2017 08:46:59
Hi

I'm trying to see if there a way to:
-instantly scroll to the bottom of inventory icons, each time the window is displayed; OR
-reverse the order of inventory icons, so that new ones appear at the top of the list

This would have to happen automatically; it would show the recently added objects, each time you open the inventory.
Title: Re: Scrolling automatically to top or bottom of inventory icons
Post by: dayowlron on Thu 01/06/2017 15:29:57
You can put in an index of where to add the inventory and if you pass in 0 it will add it at the beginning of the list.


    cEgo.AddInventory(iKey,0);
Title: Re: Scrolling automatically to top or bottom of inventory icons
Post by: bx83 on Fri 02/06/2017 01:50:13
But what about an inventory item that's already at 0? It get's bumped to 1?
Title: Re: Scrolling automatically to top or bottom of inventory icons
Post by: Snarky on Fri 02/06/2017 08:27:01
These questions are answered in fairly obvious places in the manual. For example, under "Scripting|Character functions and properties|AddInventory", it says "The new item is inserted before the current item at addAtIndex." So yes, it bumps all the items after it up one position.

As for instantly scrolling to the bottom of the inventory window, if you look under "Scripting|GUI InvWindow functions and properties" you'll see an entry for "TopItem property", which controls the scroll position of the inventory window. If you set it to gYourInventoryWindowName.TopItem - 1 it will only show the very last inventory item. If you want to show more, subtract a larger number (e.g. gYourInventoryWindowName.ItemsPerRow), making sure that it doesn't go below 0 if you only have a few inventory items.