Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Draw Rectangle surrounding item in inventory.

Featured Replies

How would you get the x and y coordinates on the screen of the inventory item? It's probably super simple I just can't figure it out.

There is no native support in the Item class, or even ItemContainer for that matter. You (sadly) need to make an inventory destination and get the rectangle through there.

 

EDIT: For bank, you can get it like so:

public Rectangle getRectForItem(Item i) {
    int slot = getBank().getSlot(i);
    int tab = getBank().getTabForAbsoluteSlot(slot);
    return getBank().getAbsoluteSlotPosition(tab, slot);
}

Edited by Bobrocket

  • Author
InventorySlotDestination.getSlot(inventory.getSlot(item))

returns a rectangle

 

 

That makes it super simple. Thanks dude!

 

There is no native support in the Item class, or even ItemContainer for that matter. You (sadly) need to make an inventory destination and get the rectangle through there.

 

Thank you for the information......

Unfortunately from the current api it seems you can only draw the first slot as mousedestination returns the first item in the inventory (L->R,T->B)

 

But in order not to overlap the number, you can do something like:

g.drawRect(
								(int) this.inventory
										.getMouseDestination(
												this.inventory.getSlot(item))
										.getBoundingBox().getX() - 1,
								(int) this.inventory
										.getMouseDestination(
												this.inventory.getSlot(item))
										.getBoundingBox().getY() - 1,
								(int) this.inventory
										.getMouseDestination(
												this.inventory.getSlot(item))
										.getBoundingBox().getWidth() + 2,
								(int) this.inventory
										.getMouseDestination(
												this.inventory.getSlot(item))
										.getBoundingBox().getHeight() + 2);

where the additions correct the rectangle dimensions

 

apa

  • Author

Unfortunately from the current api it seems you can only draw the first slot as mousedestination returns the first item in the inventory (L->R,T->cool.png

 

But in order not to overlap the number, you can do something like:

g.drawRect(
								(int) this.inventory
										.getMouseDestination(
												this.inventory.getSlot(item))
										.getBoundingBox().getX() - 1,
								(int) this.inventory
										.getMouseDestination(
												this.inventory.getSlot(item))
										.getBoundingBox().getY() - 1,
								(int) this.inventory
										.getMouseDestination(
												this.inventory.getSlot(item))
										.getBoundingBox().getWidth() + 2,
								(int) this.inventory
										.getMouseDestination(
												this.inventory.getSlot(item))
										.getBoundingBox().getHeight() + 2);

where the additions correct the rectangle dimensions

 

apa

 

 

Actually this is the method i went with:

if (getInventory().contains(other)) {
	Rectangle rec = new Rectangle(InventorySlotDestination.getSlot(inventory.getSlot(other)));
	g.setColor(Color.ORANGE);
	g.draw(rec);
}

 

Actually this is the method i went with:

if (getInventory().contains(other)) {
	Rectangle rec = new Rectangle(InventorySlotDestination.getSlot(inventory.getSlot(other)));
	g.setColor(Color.ORANGE);
	g.draw(rec);
}

 

That will work just fine too however the rect may overlap with the stack size should the item be stackable

 

apa

  • Author

 

There is no native support in the Item class, or even ItemContainer for that matter. You (sadly) need to make an inventory destination and get the rectangle through there.

 

EDIT: For bank, you can get it like so:

public Rectangle getRectForItem(Item i) {
    int slot = getBank().getSlot(i);
    int tab = getBank().getTabForAbsoluteSlot(slot);
    return getBank().getAbsoluteSlotPosition(tab, slot);
}

 

 

This method isn't working for drawing in bank. Not sure why, it seems logical but it just wont draw the rect in the right spot. It's drawing it on a completely different item.

This method isn't working for drawing in bank. Not sure why, it seems logical but it just wont draw the rect in the right spot. It's drawing it on a completely different item.

 

The bank API might not have been updated recently then, no clue lmao

  • Author

The bank API might not have been updated recently then, no clue lmao

 

Just to be sure i'm not crazy, proper usage could be

if (getBank().isOpen()) {
    g.draw(getRectForItem(getBank().getItem(toMake2));
}

assuming toMake2 returns an int or a string.

Just to be sure i'm not crazy, proper usage could be

if (getBank().isOpen()) {
    g.draw(getRectForItem(getBank().getItem(toMake2));
}

assuming toMake2 returns an int or a string.

 

g.draw(new BankSlotDestination(bot, bank.getSlot(ITEM_ID_OR_SOMETHING)).getBoundingBox());
  • Author
g.draw(new BankSlotDestination(bot, bank.getSlot(ITEM_ID_OR_SOMETHING)).getBoundingBox());

 

 

Hngh dat coding. You're a smart cookie. Thanks dude.

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.