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.

Trouble with looting the last item

Featured Replies

I'm working on a looting script. 

let's say I do 

 GroundItem tuna = getGroundItems().closest("tuna");

and there are 10 tunas that are close to me (have the same X and Y positions) 

now Instead of  looting starting from the first tuna, I want to loot starting from the last tuna. :xboge:

I'm usually able to find my way around the documentation easily but I can't seem to find a way to do this and I'm sure there must be some clean way to do it.

My attempt for a general function was something like this. (you might want to skip that)

Spoiler

public GroundItem selectLastItem(String itemName) {
 GroundItem item = getGroundItems().closest(itemName); //because I'll need the X and Y position of the closest tuna to get the full list

 List < GroundItem > items = getGroundItems().get(item.getX(), item.getY()); //get list of all items in the position of the closest tuna

 for (int i = items.size(); i >= 0; i--) {
  if (items.get(i).getName().equals(itemName)) {
   return items.get(i); //return last the last item in the list
  }
 }
 return null;

}
GroundItem tuna = selectLastItem("Tuna"); //then call the function like this
tuna.interact("Take"); //interact with the last tuna

 

Thanks a lot in advance! 

Edited by Spider

I would use getGroundItems().getAll(), stream the results and filter through them for Tuna or whatever items. You can them sort this List using a comparator and your player's distance to the GroundItem.

EDIT: I read the question wrong, I would check out the Menu class.

Edited by Night

  • Author
On 9/19/2018 at 3:40 AM, Night said:

I would use getGroundItems().getAll(), stream the results and filter through them for Tuna or whatever items. You can them sort this List using a comparator and your player's distance to the GroundItem.

EDIT: I read the question wrong, I would check out the Menu class.

 

On 9/19/2018 at 8:13 AM, Juggles said:

Yeah menu class as Night stated. Open menu -> click last option 

awesome thanks guys

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.