Jump to content

inventory.contains slow?


Novak

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...