Inventory item count and Scroll...

Started by Slasher, Wed 14/05/2014 22:18:01

Previous topic - Next topic

Slasher

Hi,

I am trying to re-script around this piece of script.

Code: ags

void on_event(EventType event, int data) {

  if (event == eEventLoseInventory) {
    int ic = InventoryWindow3.ItemCount; 
    //invCustomInv.ItemCount;
    if ((ic/6)*6 == ic && InventoryWindow3.TopItem == ic-6) 

InventoryWindow3.ScrollUp();
 }
  if(event == eEventAddInventory && mouse.Mode == eModeWalkto)
 {
  mouse.Mode = eModeInteract;


My Inventory window has one column showing 6 items at a time, if bottom one is used I want the window to scroll up. Would you assist me please.. Without having to put TopItem in every room.

cheers



Khris

I tested this and it looks like TopItem isn't updated in this special case, meaning it will still point to the item index that has just been removed.
Which means all that should be necessary in order to fix this is to change "== ic-6" to "== ic".

Btw, a more future-proof solution is to replace all sixes with InventoryWindow3.ItemsPerRow, altough this won't hold up when you decide to make the InvWindow more than one row tall.

One catch-all method I used in the past is to calculate the coordinates of the leftmost item slot in the bottom row, then check whether InventoryItem.GetAtScreenXY returns null there.

SMF spam blocked by CleanTalk