Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Question Where am I going wrong?

Joined
Oct 4, 2016
Messages
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();
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?
 
Go check out new bots and give helpful feedback.
Joined
Jan 31, 2016
Messages
5,413
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 = GameObjects.newQuery().names("Clay oven").results().nearest();
System.out.println("Trying to use our monkfish on the oven");
SpriteItem rawMonks = Inventory.newQuery().names("Raw monkfish").results().last();
if(rawMonks != null && clayOvern != null){
if((Option option = ChatDialog.getOption("Cook All")) == null && Inventory.getSelectedItem() == null && rawMonks.click()){
Execution.delayUntil(() -> Inventory.getSelectedItem().equals(rawMonks));
if(clayOven.interact("Use",rawMonks.getDefinition().getName())){
Execution.delayUntil(() -> Inventory.getSelectedItem() == null, 5000);
}
}
else if(option != null && option.select()){
Execution.delayUntil(() -> Players.getLocal().getAnimationId() != -1, 5000);
Execution.delayUntil(() -> Players.getLocal().getAnimationId() == -1, () -> Players.getLocal.getAnimationId != -1, 5000);
}
}
I'm new to the API but not new to coding, can someone tell me where I'm going wrong here?
I fixed them in the quotes.
Idk if that's everything. Just what i thought of adding.
 
Joined
Sep 25, 2016
Messages
8
Possible fix for the clay oven interaction:
Java:
clayOven.interact("Use", "Raw monkfish -> Clay oven")

Possible fix for the make all interaction:
Java:
public void selectOption() {
    getOption("Make All").ifPresent(interfaceComponent -> {
        if (interfaceComponent.isVisible() && interfaceComponent.click()) {
            Execution.delayUntil(() -> (interfaceComponent == null || !interfaceComponent.isVisible()), 300, 800);
        }
    });
}

public Optional<InterfaceComponent> getOption(String makeOption) {
    InterfaceComponent component = Interfaces.newQuery().textContains(makeOption).visible().results().first();
    return Optional.ofNullable(component);
}


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.
 
Top