Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
  • Get GameObjects on Area


    PrimoFernando
     Share

    Recommended Posts

    private final Filter<GameObject> tree_filter = new Filter<GameObject>() {

    @Override

    public boolean match(GameObject go) {

     

    if (go == null) {

    return false;

    }

     

    if (!cutArea.contains(go)) {

    return false;

    }

    return true;

    }

    };

     

    GameObject tree = getGameObjects().closest(tree_filter);

    Link to comment
    Share on other sites


    Lets say you hypothetically defined your Area as, cuttingArea. Your hatchet as Axe & stored values for the trees, this workaround code might help:

    if (!cuttingArea.contains(getPlayers().myPlayers().getTile()) && getInventory().contains(Axe)) {
    Tile[] tiles = cuttingArea.getTiles();
    Tile cuttingAreaTiles = tiles[Calculations.random(0, tiles.length - 1)];
    if (cuttingAreaTiles != null) {
    getWalking().walk(cuttingAreaTiles); //If you're not in the Area defined, this will
    //walk you to a random tile inside it

    else { //else, if you certainly are in the wcing Area, then execute your chopping actions
    if (tree != null && tree.isOnScreen()) {
    tree.interact("Chop down");

    }
    }
    }
    Link to comment
    Share on other sites

     

    private final Filter tree_filter = new Filter() {
    @Override
    public boolean match(GameObject go) {
     
    if (go == null) {
    return false;
    }
     
    if (!cutArea.contains(go)) {
    return false;
    }
    return true;
    }
    };
     
    GameObject tree = getGameObjects().closest(tree_filter);

     

     

    You can simplify that filter a lot with just this:

    return go != null && cutArea.contains(go);
    
    Link to comment
    Share on other sites

     Share

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.