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
  • help to catch gameob.ject


    abouhanafy87

    Recommended Posts

    public void checkRocks(){
        rok1 = GameObjects.getTopObjectOnTile(new Tile(2501,5066, 0));
        rok2 = GameObjects.getTopObjectOnTile(new Tile(2498,5065, 0));
        rok3 = GameObjects.getTopObjectOnTile(new Tile(2504,5059, 0));
    
        if (rok1 != null){
            if(rok1.exists() && rok1.getID()==oreID && !rock1) {
                rock1 = true;
                log("rock 1 is now light ..o..");//this is work
            }
        }else {
            if(rock1){
                rock1 = false;
                log("rock 1 is gone *");
            }
        }
        if (rok2 != null){
            if(rok2.exists() && rok2.getID()==oreID && !rock2) {
                rock2 = true;
                log("rock 2 is now light ..oo..");
            }
        }else {
            if(rock2) {
                rock2 = false;
                log("rock 2 is gone **");// here not work
            }
        }
        if (rok3 != null){
            if(rok3.exists() && rok3.getID()==oreID && !rock3) {
                rock3 = true;
                log("rock 3 is now light ..ooo..");
            }
        }else {
            if(rock3) {
                rock3 = false;
                log("rock 3 is gone ***");
            }
        }
    }
    Link to comment
    Share on other sites

    So you can simplify it a bit but depends what your trying to do:

     

    Gameobject rock = Gameobjects.closest(oreID);

     

    Or to check only specific tiles like you are in your example you could use a filter:

        int oreID = 123;
        List<Tile> rockTiles = Arrays.asList(new Tile(2501,5066, 0),new Tile(2498,5065, 0),new Tile(2504,5059, 0));
        GameObject rock = GameObjects.closest((g) -> g != null && g.getID() == oreID && rockTiles.contains(g.getTile()));

     

    If you are trying to see if the rock has been mined already or not, check its colour once rock != null

    Link to comment
    Share on other sites

    • 2 weeks later...
    On 7/20/2021 at 2:00 AM, abouhanafy87 said:
    public void checkRocks(){
        rok1 = GameObjects.getTopObjectOnTile(new Tile(2501,5066, 0));
        rok2 = GameObjects.getTopObjectOnTile(new Tile(2498,5065, 0));
        rok3 = GameObjects.getTopObjectOnTile(new Tile(2504,5059, 0));
    
        if (rok1 != null){
            if(rok1.exists() && rok1.getID()==oreID && !rock1) {
                rock1 = true;
                log("rock 1 is now light ..o..");//this is work
            }
        }else {
            if(rock1){
                rock1 = false;
                log("rock 1 is gone *");
            }
        }
        if (rok2 != null){
            if(rok2.exists() && rok2.getID()==oreID && !rock2) {
                rock2 = true;
                log("rock 2 is now light ..oo..");
            }
        }else {
            if(rock2) {
                rock2 = false;
                log("rock 2 is gone **");// here not work
            }
        }
        if (rok3 != null){
            if(rok3.exists() && rok3.getID()==oreID && !rock3) {
                rock3 = true;
                log("rock 3 is now light ..ooo..");
            }
        }else {
            if(rock3) {
                rock3 = false;
                log("rock 3 is gone ***");
            }
        }
    }

    Have a look at some guides you're doing some weird things 

    Comment above is the basics of how to interact with objects ^

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • 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.