Qiwi 0 Share Posted October 28, 2022 (edited) GameObject obj = GameObjects.closest("obj"); //logic and things otherObj.interact("otherObj"); Magic.castSpell(Normal.teleport); Sleep.sleepUntil(() -> obj != null, 12000); //logic and things This is my code however its pretty slow detecting the object, is there a way to optimize this? Sleep.sleepUntil(() -> bank.exists() == true, 12000); for some reason this always returns True, I'm out of ideas also tried doing the distance math, and sleeping ticks until we've theoretically loaded a bank; this would force me to do run energy handling and i cba for a script this simple (my first time for scripting and java) Edited October 28, 2022 by Qiwi tried some things Link to comment Share on other sites More sharing options...
Qiwi 0 Author Share Posted October 29, 2022 (edited) Well its 6 hours later and ive come to a conclusion: im over-complicating a problem in a language I dont understand yet; Ill write needlessly complex solutions all day as long as I know what im doing. The root problem was multiple clicks causing pathing issues, so I just slapped a boolean on it. Now we're booling too GameObject obj = GameObjects.closest("obj"); boolean booling = false; //logic and things if (!booling) { otherObj.interact("otherObj"); Magic.castSpell(Normal.teleport); booling = true; //Sleep.sleepUntil(() -> obj != null, 12000); } I guess I'll leave this hear maybe someone will find it helpful Edited October 29, 2022 by Qiwi Link to comment Share on other sites More sharing options...
camelCase 238 Share Posted October 29, 2022 the sleep until will never work because "obj" is an object not a reference to GameObjects#closest, once its null it never changes unless you reassign it, youd need to do something like Sleep.sleepUntil(() -> GameObjects.closest("whatever") != null, 12_000) note that this does not update obj so object would still be null, but hopefully you are returning right after that so it should be okay 1 hour ago, Qiwi said: if (!booling): wrong language brah, {} to denote code blocks ImLife 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now