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
  • How to check if a certain object code is present on a x,y coordinate


    Light17

    Recommended Posts

    How do I do this?

                          GameObject Tree = getGameObjects().getTopObjectOnTile(new Tile(3170,3454,0));
                                         
                        if(Tree.equals(1278)) {

    Im stuck

    Link to comment
    Share on other sites

    I'm still new scripting here but let me give this a shot.. I believe you can check if the GameObject is null.

    GameObject tree= getGameObjects().getTopObjectOnTile(new Tile(3170, 3454, 0));
    
    if (tree != null) {
    	//Tree Object is on given tile
        //interact
    } else {
    	//tree Object isn't on given tile
    }

     

    Link to comment
    Share on other sites

    • 3 weeks later...

     

    // Tile you want to check (x,y,z)
    Tile tile = new Tile(3170, 3454, 0);
    
    // Object you want to check
    GameObject tree = getGameObjects.closest("Tree");
    
    if(tree.getTile().equals(tile)){
      // tile has a tree
     else {
      // no tree
     }

     

    Link to comment
    Share on other sites

    8 hours ago, Stoned said:

     

    
    // Tile you want to check (x,y,z)
    Tile tile = new Tile(3170, 3454, 0);
    
    // Object you want to check
    GameObject tree = getGameObjects.closest("Tree");
    
    if(tree.getTile().equals(tile)){
      // tile has a tree
     else {
      // no tree
     }

     

     

    // Object you want to check
    GameObject tree = getGameObjects().closest(f -> f.getName().equals("Tree") && f.getTile().equals(new Tile(3170, 3454, 0)));
    
    if(tree != null){
      // tile has a tree
     else {
      // no tree
     }
    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.