jonis5s 0 Share Posted July 30, 2018 So I just started scripting for fun, and I got a problem with my script. I am trying to make a cowhide looter just to learn the api. When the script is trying to pick up a cowhide, sometimes it doesn't seem to realise that the cowhide isn't there anymore, so it just right clicks where the cowhide was before and then loops like this like 3-5 times. This happens probably about one in three times, and it bothers me. This is the code that I made for looting: case loot: log("looting cowhide"); GroundItem cowhide = getGroundItems().closest("Cowhide"); if (cowhide != null){ cowhide.interact("Take"); } sleepWhile(() -> getLocalPlayer().isMoving(), 30000); break; What am I doing wrong? Because it's around midnight for me, and I got work tomorrow, I'll hit the bed and check in for answers tomorrow Link to comment Share on other sites More sharing options...
Volta 183 Share Posted July 31, 2018 if (cowhide != null && cowhide.exists()){ cowhide.interact("Take"); } Link to comment Share on other sites More sharing options...
Eclipseop 194 Share Posted July 31, 2018 49 minutes ago, Volta said: if (cowhide != null && cowhide.exists()){ cowhide.interact("Take"); } y the double null check. that is all exists does xd Link to comment Share on other sites More sharing options...
jonis5s 0 Author Share Posted July 31, 2018 5 hours ago, Volta said: if (cowhide != null && cowhide.exists()){ cowhide.interact("Take"); } I tried that, but found that it did the same thing. Link to comment Share on other sites More sharing options...
Articron 738 Share Posted July 31, 2018 Interact is a boolean in itself too, try this: if (cowhide != null && cowhide.interact("Take") { MethodProvider.sleepUntil(() -> !cowhide.exists(), 2000); } Link to comment Share on other sites More sharing options...
Pengu 23 Share Posted July 31, 2018 I would suggest rather using a sleepUntil. Your timeout on ur sleep is also 30 seconds which is unnecessary in this case. Try this: GroundItem cowhide = getGroundItems().closest("Cowhide"); if (cowhide != null) { cowhide.interact("Take"); sleepUntil(() -> !cowhide.exists(), 3000); } Link to comment Share on other sites More sharing options...
jonis5s 0 Author Share Posted July 31, 2018 13 hours ago, Articron said: Interact is a boolean in itself too, try this: if (cowhide != null && cowhide.interact("Take") { MethodProvider.sleepUntil(() -> !cowhide.exists(), 2000); } That really did the trick, thank you! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.