Novak Posted December 4, 2014 Author Share Posted December 4, 2014 (edited) 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 Called Sleep Called Sleep Called Sleep Called Sleep Called Sleep Called Sleep Called Sleep Called Sleep Called Sleep Called Sleep Called Sleep Called Sleep Called Sleep Called Sleep Called Sleep Called Sleep Called Sleep Called Sleep Called Sleep Called Sleep Called Sleep Called Sleep Called Sleep Called Sleep Called Sleep Called Sleep Called Sleep Called Sleep Called Sleep Called Sleep Called Sleep Called Sleep Called Sleep Called Sleep Called Sleep Called Sleep Called Sleep Called Sleep Called Sleep Called 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. sure, but you are arguing over a minimal cpu hit which is not what i am asking. I am asking why .contains is getting updated so late after the inventory has changed. calling it over should not affect what the output of the call is and also: yours says if inventory contains item: sleep for 5 seconds, because there is no condition for the for statement except that i is less than 100. Edited December 4, 2014 by Novak Link to comment Share on other sites More sharing options...
Swizzbeat Posted December 4, 2014 Share Posted December 4, 2014 (edited) The game only updates every tick (600 ms) so idk what you're idea is with checking after only 50 ms.... Also, Conditional sleeps exist for a reason. Edited December 4, 2014 by Swizzbeat Link to comment Share on other sites More sharing options...
Joseph Posted December 4, 2014 Share Posted December 4, 2014 so im a bit confused, what exactly are you trying to accomplish here? Your saying innvnetory.contains is slow? its a boolean what you mean. Are your rying to say the deposit method is slow? Link to comment Share on other sites More sharing options...
Novak Posted December 4, 2014 Author Share Posted December 4, 2014 (edited) so im a bit confused, what exactly are you trying to accomplish here? Your saying innvnetory.contains is slow? its a boolean what you mean. Are your rying to say the deposit method is slow? no. im saying the inventory.contains does not update its value(true/false) for a long time after it is actually true/false. example: i deposit item A into the bank from my inventory. when the item disappears, inventory.contains should be false. instead, it is still true for another couple seconds, slowing down the script Edited December 4, 2014 by Novak Link to comment Share on other sites More sharing options...
Joseph Posted December 4, 2014 Share Posted December 4, 2014 thats sad to hear, but wouldnt the value change after it finishes looping? Link to comment Share on other sites More sharing options...
Novak Posted December 4, 2014 Author Share Posted December 4, 2014 thats sad to hear, but wouldnt the value change after it finishes looping? in the OP i state i am using a for loop that sleeps until inventory.contains is no longer true, so it wont exit that loop until it is false OR it times out at 5 seconds Link to comment Share on other sites More sharing options...
Joseph Posted December 4, 2014 Share Posted December 4, 2014 in the OP i state i am using a for loop that sleeps until inventory.contains is no longer true, so it wont exit that loop until it is false OR it times out at 5 seconds i meant shouldnt the value change after the onLoop finishes looping though? thats what i think. I never really had a problem with inventory.contains Link to comment Share on other sites More sharing options...