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
  • Can someone help me check a tile to see if it is empty and if so make a fire?


    snailmail12

    Recommended Posts

    Can someone help me check a tile to see if it is empty and if so make a fire? I cant get my head round it.

    I tried  to check if there is a fire on the tile i am standing on but it doesnt worlk can anyone help me out?

    GameObject logOnFire =GameObjects.closest(Fire);
    if (!logOnFire.getTile().equals(Players.localPlayer().getTile())){
    Link to comment
    Share on other sites

    I'm sure there's a more elegant way to do this, but for my Firemaking script I just checked to see if there is a fire on my tile:

    GameObject fire = GameObjects.closest(FIRE);
    if (fire != null) {
    	if(fire.distance(getLocalPlayer()) == 0) {
    		// There is a fire on the player's tile
    	} else {
    		// There is NOT a fire on the player's tile
    	}
    }

     

    Link to comment
    Share on other sites

    I recommend you do something like this. You can use GameObject#getObjectsOnTile() instead as it uses less resources than having it try to find the closest every time
     

    private static final Filter<GameObject> FIRE_FILTER = x -> x != null && x.getName() != null && x.getName().toLowerCase().contains("fire");
    
    public static GameObject getFireOnPlayer(){
      GameObject[] objs = GameObjects.getObjectsOnTile(Players.localPlayer().getTile());
      if(objs != null){
        return Arrays.stream(objs).filter(FIRE_FILTER::match).findFirst().orElse(null);
      }
    
      return null;
    }
    
    // Then just use it like this
    
    GameObject fire = getFireOnPlayer();
    if(fire != null){
    	// There is a fire underneath the player
    }else{
    	// No fire
    }



     

    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.