Mouse is not always accurate

Discussion in 'Developer Support' started by not_mallard, Jul 25, 2015.

  1. I wrote a bot to make Anchovy pizza for me.
    It kind of works...

    Sometimes it mis-clicks and then eats things, or breaks in other scary ways.

    Here's a video to showcase the problem


    This is the code I'm using to make the pizzas

    PHP:
    1. SpriteItem anchovies = Inventory.getItems("Anchovies").first();
    2. SpriteItem pizza = Inventory.getItems("Plain pizza").first();
    3. anchovies.interact("Use");
    4.  
    5. Execution.delay(300, 500);
    6.  
    7. pizza.click();
    8.  
    9. Execution.delayUntil(() -> Interfaces.getLoaded(Interfaces.getTextEqualsFilter("Anchovy pizza")).first() != null, 500, 1000);
    10.  
    11. InterfaceComponent ic = Interfaces.getAt(309, 6);
    12.  
    13. if (ic != null)
    14.     ic.click();
    15.  
    16. Execution.delayUntil(() -> Players.getLocal().getAnimationId() == -1, 500, 1000);
     
  2. Try using interact() instead of click() as you can the force the mouse to right click the item and choose the correct option, you should also slow down the bot by adding logic so that you only delayUntil after interactions are successful, something like this:


    Code (Text):
    1. if (ChatDialog.getOptions().isEmpty()) {
    2.             // We don't have the option to make pizza yet
    3.             if (anchovies != null && anchovies.interact("Use")) {
    4.                 if (pizza != null && pizza.click()) {
    5.                     Execution.delayUntil(() -> !ChatDialog.getOptions().isEmpty(), 1000, 2500);
    6.                 }
    7.             }
    8.         } else {
    9.             // The make pizza menu is likely open
    10.             InterfaceComponent pizzaInterface = Interfaces.getAt(309, 6);
    11.             if (pizzaInterface != null && pizzaInterface.click()) {
    12.                 Execution.delayUntil(() -> Players.getLocal().getAnimationId() == -1, 500, 1000);
    13.             }
    14.         }
     
  3. Thanks but ChatDialog.getOptions().isEmpty() seems to always be true. Is there a method that I could use to replace this?
     
  4. Check if the interface you're trying to access != null and isVisible(). If that returns true, then you know it's visible. If either of those return false, then you know it's not there yet, so you need to interact with your pizza and anchovies.

    tl;'dr: There's no logic there. It's just a list of things to do which will fire every so often.

    And @Arbiter why is this shit so borked? http://vgy.me/vQvqf6.png (the layout)
     
  5. Here's the method I ended up using
    Code (Text):
    1. private boolean hasPizzaBox() {
    2.         return Interfaces.getAt(309, 6) != null && Interfaces.getAt(309, 6).isVisible();
    3.     }
     
  6. I don't see why you need to make it into another method? Are you calling it more than once?
     
  7. Calling it in two places.
    In the first if statement (to check if I need to click the anchovies or if I need to click the interface) and also in the Execution.delayUntil
     
  8. Fair enough.
     

Share This Page

Loading...