Question Where am I going wrong?

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

  1. 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();
    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. I fixed them in the quotes.
    Idk if that's everything. Just what i thought of adding.
  3. Possible fix for the clay oven interaction:
    Code (Java):
    2. clayOven.interact("Use", "Raw monkfish -> Clay oven")
    Possible fix for the make all interaction:
    Code (Java):
    2. public void selectOption() {
    3.     getOption("Make All").ifPresent(interfaceComponent -> {
    4.         if (interfaceComponent.isVisible() && {
    5.             Execution.delayUntil(() -> (interfaceComponent == null || !interfaceComponent.isVisible()), 300, 800);
    6.         }
    7.     });
    8. }
    10. public Optional<InterfaceComponent> getOption(String makeOption) {
    11.     InterfaceComponent component = Interfaces.newQuery().textContains(makeOption).visible().results().first();
    12.     return Optional.ofNullable(component);
    13. }

    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