Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Slasher on Fri 14/10/2016 13:45:02

Title: SOLVED: Inventory count and Scroll up problem
Post by: Slasher on Fri 14/10/2016 13:45:02
Hi

Something is not quite right: InventoryWindow1 does not Scroll Up when a Row is empty.

One Row shows at a time.

A Row has a max of 7 inv items. When the last inv item is used (8th) in the bottom Row it should Scroll up to Top Row to show Row of 7 inv items.

Code (ags) Select

function on_event(EventType event, int data)
{
 
if (event == eEventLoseInventory) {
  int ic = InventoryWindow1.ItemCount;
  if ((ic/7)*7 == ic && InventoryWindow1.TopItem == ic) InventoryWindow1.ScrollUp();
 
}
}


cheers for any help

Title: Re: Inventory count and Scroll up problem
Post by: Crimson Wizard on Fri 14/10/2016 14:03:33
I have a small tip:
if ((ic/7)*7 == ic)
Simplier way to do same is:
if (ic%7 == 0)

The % operator means "remainder of the division". The above script means "when ic can be divided by 7 without remainder".


Although, I am not sure why you need to calculate that. Maybe my head is not working well right now, but is not it possible to do just
if (InventoryWindow1.TopItem >= InventoryWindow1.ItemCount)
Title: SOLVED{ Re: Inventory count and Scroll up problem
Post by: Slasher on Fri 14/10/2016 14:52:42
Thanks Crimson,

Got it working.

cheers

slasher