SOLVED: Inventory count and Scroll up problem

Started by Slasher, Fri 14/10/2016 13:45:02

Previous topic - Next topic

Slasher

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

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


Crimson Wizard

#1
I have a small tip:
Code: ags
if ((ic/7)*7 == ic)

Simplier way to do same is:
Code: ags
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
Code: ags
if (InventoryWindow1.TopItem >= InventoryWindow1.ItemCount)


Slasher

Thanks Crimson,

Got it working.

cheers

slasher

SMF spam blocked by CleanTalk