How can I check if my last item is showed in the inventory or not?

Started by RoliX, Wed 20/04/2011 12:55:20

Previous topic - Next topic

RoliX

I want to scroll left-right in my inventory...
The scrolling left is working(stop scrolling when TopItem = 0).
But I can't set up the scrolling right part... I want the inventory to not scroll right anymore, if the last item is showed.

My script is like:

Scrolling left:

if (invCustomInv.TopItem > 0) {

 invCustomInv.TopItem -=1;
}



Scrolling right:


if (? ? ? ?)
{
invCustomInv.TopItem +=1;
}


Please help!

Thanks.

Khris

I assume you have a single row of items, right?
Thus, invCustomInv.ItemsPerRow will give you the number of visible items while invCustomInv.ItemCount will give you the number of total items.

As an example: 10 items total (0-9), 4 visible (6-9). TopItem's max value is therefore ItemCount - ItemsPerRow.

Code: ags
  if (invCustomInv.TopItem < invCustomInv.ItemCount - invCustomInv.ItemsPerRow) {
    invCustomInv.TopItem +=1;
  }

RoliX

Thank you very much! I expected a trick, just like this :D

Khris

You're welcome :)

It isn't really a trick though, it's simply programming.

SMF spam blocked by CleanTalk