Solved: Inventory window top item snag

Started by steptoe, Thu 27/10/2011 08:55:47

Previous topic - Next topic

steptoe

I have a snag: Inv window does not auto scroll to top item and shows empty bottom row at somepoint in the game.

I do not use inv 1 or 2 and start with inv 3 from the beginning which stays til the end and I also use their ID's.

However, sometime in the game I end up with a blank row.

I have 3 Items per row.

I am using the below code in rooms where appropriate:

Code: ags

invCustomInv.TopItem = 3;


Any help/advice would be great.

EDIT

This appears to work:

Code: ags
 invCustomInv.ScrollUp();



cheers



Khris

Where did you put that line? Inside on_event/eEventLoseInventory?

steptoe

Quote from: LeKhris on Thu 27/10/2011 09:23:55
Where did you put that line? Inside on_event/eEventLoseInventory?

Hi

well, i think there may be a problem if i put in global rep exec so i put it in room on event such as when you use (or lose) an inv item, especially where i used to get a blank row.

advice welcomed

cheers


Khris

Putting it in rep_ex will prevent the player from scrolling down, ever.
Putting it in every interaction where the player loses an item is tedious and unnecessary.

on_event is the right place; just add this to the global script:

Code: ags
void on_event(EventType event, int data) {

  if (event == eEventLoseInventory) {
    int ic = invCustomInv.ItemCount;
    if ((ic/3)*3 == ic && invCustomInv.TopItem == ic-3) invCustomInv.ScrollUp();
  }
}


Every time the player loses an item, AGS checks whether there's now an empty row and if so, scrolls up.

steptoe

I have just added your code to Global with no problem..

many thanks LeKhris

cheers

steptoe



SMF spam blocked by CleanTalk