Qiwi 0 Posted October 28, 2022 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)
Qiwi 0 Author Posted October 29, 2022 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
camelCase 324 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
Recommended Posts
Archived
This topic is now archived and is closed to further replies.