Welcome!

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

Sign up now!

Bug Client aren't returning more than 1 nearest object

Joined
Jan 25, 2015
Messages
121
Hello, I started to code some bots but the client don't interact with all objects avaliable, as the nearests. After problems I tried write a simple code to check if the problem was in my code or no. Look:

JavaScript:
public class Test extends Task {

    @Override
    public void execute() {

        GameObject tree = GameObjects.newQuery().names("Willow").results().nearest();

        if (tree != null){

            if (tree.interact("Chop down")){

                System.out.println("Chopping...");
            }
        }
    }

    @Override
    public boolean validate() {

        return Players.getLocal().getAnimationId() == -1 && !Inventory.isFull();
    }
}

If I run this, the local player will only chop the nearest tree. When the tree falls, character don't go interact with the next avaliable object, just stuck, without log messages.

Runemate version: 2.48.0
Game affected: RS3

EDIT:

I tried to use LoopingBot instead Task bot and got the same problem. This is the test in LoopingBot:

JavaScript:
public class Main extends LoopingBot {

    @Override
    public void onLoop() {
        GameObject t = GameObjects.newQuery().names("Willow").results().nearest();

        if (Players.getLocal().getAnimationId() == -1 && !Inventory.isFull() && t != null){

            t.interact("Chop down");
        }
    }
}

I tried too delete my cache folders and reinstall legacy client and didn't solved the problem.
 
Last edited:
12 year old normie
Joined
Jan 8, 2015
Messages
2,769
How are you adding this task to the tasklist? Assuming you're using TaskBot.

Also, why not declare tree, initialize and nullcheck in validate() and interact with in execute()? Try to move as much to the validate() as possible that might cripple the execute() (such as nullchecking).
 
Joined
Jan 25, 2015
Messages
121
How are you adding this task to the tasklist? Assuming you're using TaskBot.

Just using add() at my TaskBot main class like:
Code:
add(new Test());

Also, why not declare tree, initialize and nullcheck in validate() and interact with in execute()? Try to move as much to the validate() as possible that might cripple the execute() (such as nullchecking).

I tried move all inicializations and verifications to validate(), as you recomended, and stil got the same state, stuck after chopping aquired tree.

This is the test code after corrections:

Code:
public class Test extends Task {

    private GameObject tree;

    @Override
    public void execute() {
        tree.interact("Chop down");
    }

    @Override
    public boolean validate() {
        tree = GameObjects.newQuery().names("Willow").results().nearest();

        return Players.getLocal().getAnimationId() == -1 &&

                !Inventory.isFull() &&

                tree != null;
    }
}
 
Top