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.

Trying to get amount of Ground items from an area or position

Featured Replies

Can't seem to get this working correctly. The value (groundTinderbox) always seems to come back as 1 no matter how many ground items there are as long as it isn't 0. I'm almost certain it could be because it isn't a stackable item, but not sure. Here is the snippet:

    public void shouldPickUpTinderboxes() throws InterruptedException
    {
        GroundItem groundTinderbox = groundItems.closest(areaDraynorVillageWiseOldManFrontOfTinderboxBookshelf, "Tinderbox");
        int emptyInventorySlots = inventory.getEmptySlots();

        if (!boolShouldPickUpTinderboxes && !boolShouldSpeakToWiseOldMan && !boolShouldBank && stringMethodSelector.contains("tinderbox_picker") && areaDraynorVillageWiseOldManFrontOfTinderboxBookshelf.contains(myPlayer()) && groundTinderbox != null && groundTinderbox.getAmount() >= emptyInventorySlots)
        {
            boolShouldPickUpTinderboxes = true;
            log("Attempting to pick tinderboxes.");
        }
        if (boolShouldPickUpTinderboxes)
        {
            if (boolShouldSpeakToWiseOldMan || boolShouldBank || !stringMethodSelector.contains("tinderbox_picker") || !areaDraynorVillageWiseOldMan.contains(myPlayer()) || groundTinderbox.getAmount() == 0 || getInventory().isFull())
            {
                boolShouldPickUpTinderboxes = false;
                log("Tinderboxes picked.");
            }
        }
    }

 

@FushigiBot Each item is a separate entity, you probably need to do something like this and use .size() for the amount
 

    public List<GroundItem> getAllTinderboxes()
    {
        return getGroundItems()
                .getAll()
                .stream()
                .filter(g -> g.getName().equals("Tinderbox")
                        && areaDraynorVillageWiseOldManFrontOfTinderboxBookshelf.contains(g.getPosition())
                        && getMap().canReach(g))
                .collect(Collectors.toList());
    }

 

  • Author
15 minutes ago, Gunman said:

@FushigiBot Each item is a separate entity, you probably need to do something like this and use .size() for the amount
 

    public List<GroundItem> getAllTinderboxes()
    {
        return getGroundItems()
                .getAll()
                .stream()
                .filter(g -> g.getName().equals("Tinderbox")
                        && areaDraynorVillageWiseOldManFrontOfTinderboxBookshelf.contains(g.getPosition())
                        && getMap().canReach(g))
                .collect(Collectors.toList());
    }

 

Yikes, thanks. Will try that now.

  • Author

It worked. Thanks!

 

    public void shouldPickUpTinderboxes() throws InterruptedException
    {
        List<GroundItem> allTinderboxes = getAllTinderboxes();
        int emptyInventorySlots = inventory.getEmptySlots();

        if (!boolShouldPickUpTinderboxes && !boolShouldSpeakToWiseOldMan && !boolShouldBank && stringMethodSelector.contains("tinderbox_picker") && areaDraynorVillageWiseOldManFrontOfTinderboxBookshelf.contains(myPlayer()) && !allTinderboxes.isEmpty() && allTinderboxes.size() >= emptyInventorySlots)
        {
            boolShouldPickUpTinderboxes = true;
            log("Attempting to pick tinderboxes.");
        }
        if (boolShouldPickUpTinderboxes)
        {
            if (boolShouldSpeakToWiseOldMan || boolShouldBank || !stringMethodSelector.contains("tinderbox_picker") || !areaDraynorVillageWiseOldMan.contains(myPlayer()) || allTinderboxes.isEmpty() || getInventory().isFull())
            {
                boolShouldPickUpTinderboxes = false;
                log("Tinderboxes picked.");
            }
        }
    }

    public List<GroundItem> getAllTinderboxes()
    {
        return getGroundItems()
                .getAll()
                .stream()
                .filter(g -> g.getName().equals("Tinderbox")
                        && areaDraynorVillageWiseOldManFrontOfTinderboxBookshelf.contains(g.getPosition())
                        && getMap().canReach(g))
                .collect(Collectors.toList());
    }

 

16 hours ago, FushigiBot said:

Can't seem to get this working correctly. The value (groundTinderbox) always seems to come back as 1 no matter how many ground items there are as long as it isn't 0. I'm almost certain it could be because it isn't a stackable item, but not sure. Here is the snippet:

    public void shouldPickUpTinderboxes() throws InterruptedException
    {
        GroundItem groundTinderbox = groundItems.closest(areaDraynorVillageWiseOldManFrontOfTinderboxBookshelf, "Tinderbox");
        int emptyInventorySlots = inventory.getEmptySlots();

        if (!boolShouldPickUpTinderboxes && !boolShouldSpeakToWiseOldMan && !boolShouldBank && stringMethodSelector.contains("tinderbox_picker") && areaDraynorVillageWiseOldManFrontOfTinderboxBookshelf.contains(myPlayer()) && groundTinderbox != null && groundTinderbox.getAmount() >= emptyInventorySlots)
        {
            boolShouldPickUpTinderboxes = true;
            log("Attempting to pick tinderboxes.");
        }
        if (boolShouldPickUpTinderboxes)
        {
            if (boolShouldSpeakToWiseOldMan || boolShouldBank || !stringMethodSelector.contains("tinderbox_picker") || !areaDraynorVillageWiseOldMan.contains(myPlayer()) || groundTinderbox.getAmount() == 0 || getInventory().isFull())
            {
                boolShouldPickUpTinderboxes = false;
                log("Tinderboxes picked.");
            }
        }
    }

 

Well the method used here is "groundItems.closest" so you will only get the one that's the closest to the player :)
What gunman said is the perfect solution, just get all and filter out what you need ^^

Edited by Khaleesi

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.