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.

inventory.contains slow?

Featured Replies

For some reason it seems really slow to me:

depositAll(uncut);
for(int i = 0; i < 100 && inventory.contains(uncut); i++) {
sleep(50);
}

is waiting a couple seconds to continue when it should respond within 50ms.  Any ideas?

Edited by Novak

  • Author

You are calling that method 100 times, just do getAmount if you want to get the amount of uncuts, or what are you trying to achieve? I will help

 

 

i want it to continue after the uncuts have left the inventory.  So it should sleep for 50ms intervals until the uncuts have left the inventory.  Instead, it is taking seconds to update which is causing it to sleep for more 50ms intervals.  The 100 is there so that if it exceeds 100 50ms intervals, it will time out and go back into the loop

Edited by Novak

  • Author
if (depositAll(uncut)) {
sleep(50);
}

should be enough

 

 

thats bad though.  Its a static sleep and it doesn't check the the item has actually left the inventory. there is nothing wrong with the logic, it has to do with how .contains is updating, which is my question

 

In response to your edit:

 

that means it will keep trying to deposit it every 50ms, which it takes longer for the item to leave the inventory than that.  So in that case it would keep spamming items to deposit until it leaves, which probably takes about a second. 1000/50 is 20, which means that it would spam the deposit 20 or so times until it left, which is very bot like.  

Edited by Novak

  • Author
if (getInventory().contains(uncut)){
for(int i = 0; i < 100; i++) {
sleep(50);
}
}

Idk, try that

 

 

that is literally the same thing as my OP, just with an unneeded if statement

  • Author

Lol my bad, I read it wrong, well IDK what else to say, just find another way to sleep after depositing items, it's really not a big issue

 

but thats not the point, my point is why does it take so long for it to update, this method worked perfect for osb1, it would respond as intended.  

Dude it's not the same thing, you just confused me..

if (getInventory().contains(uncut)){
for(int i = 0; i < 100; i++) {
sleep(50);
}
}

That is calling inventory.contains 1 time, the code you have calls it 100 times. 

Try it..

Edited by Czar

  • Author

Have you tried the new banking method I added with the release of 2.2.43?

http://osbot.org/forum/topic/62310-osbot-2243-combat-magic-and-interface-patches/

 

bank.withdraw(HashMap<String, Integer>);

 

no, but is it really faster than the manual mouse moving I wrote using mouse.move?  and does it check to make sure the items have come/left the inventory within 50ms?

For some reason it seems really slow to me:

depositAll(uncut);
for(int i = 0; i < 100 && inventory.contains(uncut); i++) {
sleep(50);
}

is waiting a couple seconds to continue when it should respond within 50ms.  Any ideas?

 

 

Dude it's not the same thing, you just confused me..

if (getInventory().contains(uncut)){
for(int i = 0; i < 100; i++) {
sleep(50);
}
}

That is calling inventory.contains 1 time, the code you have calls it 100 times. You just made me look silly -.-

 

Try it..

 

 

please explain how it calls it 100 times?  the 100 is just for the timeout, if i is less than 100 AND our inventory still contains the item, then sleep for 50.  Obviously if the item has left the inventory then the for statement no longer executes because the second condition isn't true.

Mine:

Called
Sleep
Sleep
Sleep
Sleep
Sleep
Sleep
Sleep
Sleep
Sleep
Sleep
Sleep
Sleep
Sleep
Sleep
Sleep
Sleep
Sleep
Sleep
Sleep
Sleep
Sleep
 

public boolean contains(int i) {
System.out.println("Called");
return true;
}
 
public void check() {
if (contains(0)) {
for (int i = 0; i < 100; i++) {
System.out.println("Sleep");
}
}
}

Yours

Called
Sleep
Called
Sleep
Called
Sleep
Sleep
Called
Sleep
Called
Sleep
Called
Sleep
Called
Sleep
Called
Sleep
Called
Sleep
Called
Sleep
Called
Sleep
Sleep
Called
 

public boolean contains(int i) {
System.out.println("Called");
return true;
}
 
public void check() {
for (int i = 0; i < 100 && contains(0); i++) {
System.out.println("Sleep");
}
}

Hypothetical, but yeah.

Edited by Czar

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.