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.

GroundItems see how many there is?

Featured Replies

Hi i am trying to setup a basic script that will detect if there are x amount of whatever item on ground and if there is then pick it up otherwise it would just ignore it, how would i go about doing this i've tried the following but it doesn't seem to be working thanks.

GroundItem item1 = groundItems.closest(id);
			if (item1.getAmount() >= 28) {
				item1.interact("Take");
			}

 

Create a list of lootable items and then use the grounditems with a filter to check for them :)

something like:

getGroundItems.getAll()

then just iterate through the items and pick up the ones with ur req

If I'm understanding you properly, you're looking to see if there are x amount of an item anywhere on the ground (e.g. looking for >250 coins, 3 stacks of 100 coins = 300 coins, loot all stacks). You could use a for loop to accomplish this. Something like this comes to mind. Just be careful with the while loop -- depending on your particular case, your code could get stuck there.

int amount = 0;
int itemId = <your item>;
  
for(GroundItem g : getGroundItems().getAll()) {
	if(g.getId() == itemId)
  		amount += g.getAmount();
}
  
if(amount > x) {
	GroundItem g = getGroundItems().closest(itemId);
	while(g != null) {
		g.interact("Take");
		new ConditionalSleep(10000){
			public boolean condition() throws InterruptedException {
				return !g.exists();
			}
		}.sleep();
		g = getGroundItems().closest(itemId);
	}
}

 

Edited by toxicity959

9 hours ago, DragonTTK said:

Hi i am trying to setup a basic script that will detect if there are x amount of whatever item on ground and if there is then pick it up otherwise it would just ignore it, how would i go about doing this i've tried the following but it doesn't seem to be working thanks.


GroundItem item1 = groundItems.closest(id);
			if (item1.getAmount() >= 28) {
				item1.interact("Take");
			}

 

If the item is a stacked item then what you posted should work.

If it is not however, then it will be a little more complex.

 

If you don't care if the ground items are all in the same position then you can do:

List<GroundItem> items = getGroundItems().filter(getGroundItems().getAll(), new NameFilter<>("Item name"));

if (items.size() >= 28) {
    ... 
}

 

If you want to check if the ground items are all in the same stack, then it is a little more complicated. I *think* there is a way to get the stack in the API but i'm not sure.

I can post some code if you really need.

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.