Jump to content

Less-bugged bank.scrollToSlot(slot)


darkxor

Recommended Posts

Writed simple version of scrollToSlot(int slot) that does not become stupid on first/last partially visible rows. It works maximally depending on existing scrolling functions.

public void bankScrollToSlot(int slot) throws InterruptedException{
        bank = client.getBank();
        
        int yTop = bank.getVirtualSlotPosition(0).y;
        int yBottom = bank.getVirtualSlotPosition(40).y;
        
        Rectangle rect = bank.getAbsoluteSlotPosition(slot);
        int y = rect.y;
        if(y < yTop)
            bank.scrollToSlot(slot - 8 >= 0 ? slot - 8 : slot); //scroll up
        if(y > yBottom)
            bank.scrollToSlot(slot + 8 < 400 ? slot + 8 : slot); //scroll down
    }

P.S. Did'nt test it much enough, so can contain some bugs.

Link to comment
Share on other sites

When even bother scrolling? This is a re-post of my submitted code on the Withdraw without scrolling bug thread:

public static RectangleDestination getScrollerDes(Script script, int id) {

		if (!script.client.getBank().isOpen()
				|| !script.client.getBank().contains(id))
			return null;

		int i = 0;

		for (Item next : script.client.getBank().getItems())
			if (next != null && next.getId() == id)
				break;
			else
				i++;

		i /= 2;

		return new RectangleDestination(new Rectangle(480, 68 + i, 15, 4));
	}
  • Like 1
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...