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.

How to check ground for array items?

Featured Replies

I have an array that stores every string value a person puts into it.

 

public String[] temp;

temp = itemsToPickUp.getText().split("\n");

 

(itemsToPickUp is a text box in my GUI)

 

so if the user puts in:

 

Lobster

Bones

Coins

Fire runes

 

it is stored in the array as:

temp[0] = "Lobster";

temp[1] = "Bones";

temp[2] = "Coins";

temp[3] = "Fire runes";

 

and so on for however many items they decide to add into the text box.

 

My problem now is, how do I get the bot to pick the items up off the ground.

I've tried:

 

GroundItem loot = groundItems.closest(temp);
if (!myPlayer().isAnimating()) {
loot.interact("Take");
}

 

but for some reason it only picks up the LAST item in the array, and doesn't check for any other items. So in this instance it would pick up fire runes, and nothing else.

 

How do I get the bot to check for EVERY item in the array?

Edited by computor

  • Author

Something like this??? (but this doesn't work)

for (int i = 0; i < temp.length; i++){
			GroundItem loot = groundItems.closest(temp[i]);
			loot.interact("Take");
		}

Try this: 

 

 

for (int i = 0; i < temp.length; i++){

   if (groundItems.closest(temp[i]) != null) {
            GroundItem loot = groundItems.closest(temp[i]);
            loot.interact("Take");

  }

}

       
Obviously you'll want some other stuff, like to check if your inventory is full, failsafes to make sure it does loot etc.          

Edited by Molly

  • Author

It still only picks up the last item in the list.

It still only picks up the last item in the list.

 

Ahh ok, I reread the OP and it looks like the way you're reading in data only the very last string entered is put into temp.

Sorry I was wrong that does actually work, forgive me its 4 am and I am exhausted lol. I'm not exactly sure why you are having difficulty looting. I'll look over your code real quick and see if I can spot something.

Just use this:

for (String s : temp) {
GroundItem item = this.groundItems.closest(s);
if (item != null)
if(item.interact("Take"))
sleep(random(600,1000));
}

Edited by Apaec

  • Author

@Apaec, it still only takes the last item on the list.


Here's my GUI:

private void thisWindowClosed(WindowEvent e) { //use this handler to check to see if the window is closed or not.
			temp = itemsToPickUp.getText().split("\n"); //on closing, it sets the values in itemsToPickUP to the temp[] array (defined above) after every split (new line).
		}
private void initComponents() {

			itemsToPickUp = new JTextPane();

			//======== scrollPane1 ========
			{
				scrollPane1.setViewportView(itemsToPickUp);
			}
			contentPane.add(scrollPane1);
			scrollPane1.setBounds(25, 60, 215, 105);

and here is my array:

public String[] temp;

and my loop:

		for (String s : temp) {
			GroundItem item = this.groundItems.closest(s);
			if (item != null)
				if(item.interact("Take"))
					sleep(random(600,1000));
		}

Have I done something wrong?

 

I know all the variables are stored into the array that the user puts into the scroll box because I've painted them onscreen to test to see if they were being stored correctly. I just don't know why the loop is only searching for the last item on the list.

Guest
This topic is now closed to further replies.

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.