whipz Posted February 28, 2017 Share Posted February 28, 2017 Hey guys, my conditional sleeps usually work however for ground items I seem to be having a little bit of problems; this is my code for that part GroundItem item = getGroundItems().closest("item"); if (item == null) { log("item is null"); if (!magic.isSpellSelected()) { log("Spell is not active, activating spell"); magic.castSpell(Spells.NormalSpells.TELEKINETIC_GRAB); } else { log("item is null, spell is active moving mouse to predicted spot"); hoverTile.hover(bot); sleep(random(500, 1500)); new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return item.exists(); } }.sleep(); } } no matter what I do it always seems to return true even if its not there I have tried: item != null; (this one waits until it times out then continues) item.isVisiable(); item.isOnScreen(); pretty much everything I can think of and nothing works right Quote Link to comment Share on other sites More sharing options...
k9thebeast Posted February 28, 2017 Share Posted February 28, 2017 (edited) Zammy wine grabber Anyway, you sure its returning true and its not just waiting the 5 seconds defined by the line new ConditionalSleep(5000) { // This means a max sleep of 5 seconds which is shorter than the item respawn time. // Try new ConditionalSleep(90000) { for 1.5 minutes sleep Also I would use item != null (Although there are other of doing it, suggest you test each one you can come up with for the fastest time). Also instead of a conditional sleep, you could just change it to this which is probably better practice else { if(!pos.getPolygon(bot).contains(getMouse().getPosition())){ //mouse is not hovering on tile //blah blah blah hover mouse } } Edited February 28, 2017 by k9thebeast Quote Link to comment Share on other sites More sharing options...
whipz Posted February 28, 2017 Author Share Posted February 28, 2017 9 minutes ago, k9thebeast said: Zammy wine grabber Anyway, you sure its returning true and its not just waiting the 5 seconds defined by the line new ConditionalSleep(5000) { // This means a max sleep of 5 seconds which is shorter than the item respawn time. // Try new ConditionalSleep(90000) { for 1.5 minutes sleep Also I would use item != null (Although there are other of doing it, suggest you test each one you can come up with for the fastest time). Also instead of a conditional sleep, you could just change it to this which is probably better practice else { if(!pos.getPolygon(bot).contains(getMouse().getPosition())){ //mouse is not hovering on tile //blah blah blah hover mouse } } i did have it set for after re spawn rate i was just using it so that it would work; but it always fucks up; ill give it a shot and report back Quote Link to comment Share on other sites More sharing options...
Polymorphism Posted March 1, 2017 Share Posted March 1, 2017 From what I understand you're simply trying to make the script wait until the wine is back on the table? This isn't perfect, but you could definitely build on it In your onLoop you shouldn't make the script DyanmicSleep while waiting, just don't make it do anything. onLoop(){ GroundItem item = groundItems.closest("item"); if(item != null || item.exists()){ //grab that shit } if(item == null || !item.exists()){ if(!magic.isSpellSelected()){ //check if can cast, then cast spell } if(magic.isSpellSelected()){ if(!magic.getSelectedSpellName().equalsIgnoreCase(NormalSpells.TELEKINETIC_GRAB.name())){ //deselect spell only } if(!hoverTile.getPolygon(bot).contains(mouse.getPosition()){ // hover the tile //return 600 or whatever here. Just make the script return inside onLoop() when waiting } } } } 1 Quote Link to comment Share on other sites More sharing options...
whipz Posted March 1, 2017 Author Share Posted March 1, 2017 21 minutes ago, Polymorphism said: From what I understand you're simply trying to make the script wait until the wine is back on the table? This isn't perfect, but you could definitely build on it In your onLoop you shouldn't make the script DyanmicSleep while waiting, just don't make it do anything. onLoop(){ GroundItem item = groundItems.closest("item"); if(item != null || item.exists()){ //grab that shit } if(item == null || !item.exists()){ if(!magic.isSpellSelected()){ //check if can cast, then cast spell } if(magic.isSpellSelected()){ if(!magic.getSelectedSpellName().equalsIgnoreCase(NormalSpells.TELEKINETIC_GRAB.name())){ //deselect spell only } if(!hoverTile.getPolygon(bot).contains(mouse.getPosition()){ // hover the tile //return 600 or whatever here. Just make the script return inside onLoop() when waiting } } } } thanks mate; k9's worked perfect (: Quote Link to comment Share on other sites More sharing options...
Polymorphism Posted March 1, 2017 Share Posted March 1, 2017 12 hours ago, whipz said: thanks mate; k9's worked perfect (: No problem, hadn't noticed he already put down pretty much what i did lol. Mustve been writing it up nearly the same time. Quote Link to comment Share on other sites More sharing options...