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


    Light17
     Share

    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
     }

     

    Edited by Stoned
    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

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
     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.