1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Question Where am I going wrong?

Discussion in 'Developer Support' started by Defa1t, Oct 7, 2016.

  1. Defa1t

    Joined:
    Oct 4, 2016
    Messages:
    1
    Likes Received:
    0
    I'm making a cooking bot, trying to make it use raw monks on a clay oven and then cook them all

    System.out.println("We found a clay oven");
    GameObject clayOven = query.nearest();
    System.out.println("Trying to use our monkfish on the oven");
    SpriteItem rawMonks = Inventory.newQuery().names("Raw monkfish").results().last();
    clayOven.interact("Use",rawMonks.getDefinition().getName());
    ChatDialog.getOption("Cook All");

    I'm new to the API but not new to coding, can someone tell me where I'm going wrong here?
     
  2. awesome123man

    awesome123man Go check out new bots and give helpful feedback.

    Joined:
    Jan 31, 2016
    Messages:
    5,413
    Likes Received:
    1,662
    I fixed them in the quotes.
    Idk if that's everything. Just what i thought of adding.
     
  3. Greg

    Joined:
    Sep 25, 2016
    Messages:
    8
    Likes Received:
    2
    Possible fix for the clay oven interaction:
    Code (Java):
    1.  
    2. clayOven.interact("Use", "Raw monkfish -> Clay oven")
    3.  
    Possible fix for the make all interaction:
    Code (Java):
    1.  
    2. public void selectOption() {
    3.     getOption("Make All").ifPresent(interfaceComponent -> {
    4.         if (interfaceComponent.isVisible() && interfaceComponent.click()) {
    5.             Execution.delayUntil(() -> (interfaceComponent == null || !interfaceComponent.isVisible()), 300, 800);
    6.         }
    7.     });
    8. }
    9.  
    10. public Optional<InterfaceComponent> getOption(String makeOption) {
    11.     InterfaceComponent component = Interfaces.newQuery().textContains(makeOption).visible().results().first();
    12.     return Optional.ofNullable(component);
    13. }
    14.  

    I would also consider using ample more null checks as @awesome123man added in his snippet. Other than that you didn't really say what was going wrong for you.
     
    awesome123man likes this.

Share This Page

Loading...