Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Faster way to sleep until an objext exists?


    Qiwi

    Recommended Posts

    Posted
    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)

    Posted

    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

    Posted

    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

     

     

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.