Jump to content
Sign in to follow this  
IceKontroI

Help with Conditions (EDIT: SOLVED)

Recommended Posts

EDIT: Figured it out. Needed to do

while (!stop.active()) {

    // continue walk process

}

Feel free to use this post as a reference if you are having the same problem.

I would like to add a stopping condition to a custom walking method I wrote, but I can't seem to get the condition to recalculate each time; it just keeps using the original value I fed into it on method start. Here's some pseudo code to give you an idea what I'm working with:

public static void walkMethod(RSTile[] path, Condition stop) {
	System.out.println("Beginning walk process.");
	while (stop != null && pathList.size() > 0) {
		// select tile to walk to
		// click tile
		// sleep
	}
}

And the Condition looks like:

	static Rectangle destinationArea = new Rectangle(1, 1, 4, 6);

	static Condition stoppingCondition =  new Condition() {
		public boolean active() {
			System.out.println("THIS TEXT SHOULD BE VISIBLE.");
			General.sleep(10);
			RSTile playerTile = Player.getPosition();
			Point playerPoint = new Point(playerTile.getX(), playerTile.getY());
			return destinationArea.contains(playerPoint);
		}
	};

The first thing I don't understand is what Conditions actually return. I would assume it's either true or false, but it seems to be more than that. This will help me figure out how to word my while loop so it can stop when the player's position is in the destinationArea.

The other thing I don't get is how to make the Condition run through each line whenever it's called within the containing walkMethod(). I should be seeing the "THIS TEXT SHOULD BE VISIBLE." text every time the while loop in walkMethod() iterates but it never displays.

Any insight into how I'm doing this wrong would be greatly appreciated. I wish I didn't have to ask on the forums, but there isn't any good documentation anywhere on how Conditions work (on tribot Conditions at least).

Edited by IceKontroI

Share this post


Link to post
Share on other sites

@IceKontroI

Conditions should return true if the walking method should break early, and false if it shouldn't.
 

It is encouraged to use the premade Walking methods, you can add the condition as a argument in most functions, and it will be checked constantly while walking.
Walking#walkPath would fit your case.

The stopping_condition_delay argument is the amount of 'sleep' that is used while constantly checking your condition during walking.

 

Please don't be afraid to ask :) I think many of us would be glad to help you.

Share this post


Link to post
Share on other sites
3 minutes ago, IceKontroI said:

@laniax thank you, but as it turns out I figured out the problem almost immediately after posting. Turns out you can't check if the Condition == a boolean value, but you can check if the Condition.active() == a boolean value, which solved the problem.

That is correct, but it is still recommended to use the Walking methods, since it will check your condition async instead of, for example, only before clicking.
It has extra antiban as well.

Share this post


Link to post
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
Sign in to follow this  

  • Our picks

    • This update will:

      Fix the RSMenuNode bug which also fixes the bug with bank opening


      Fix the incorrect object positions bug


      Fix and re-enable the LG Objects API Accelerator


      Fix the RSObject#getAllTiles bug
        • Like
      • 22 replies
    • Try our development release by checking "Development Release" on the TRiBot Loader. Note that these new features are currently in beta.

      This release features:

      Re-sizable mode support for both LG and the regular client


      Slightly improved login bot


      Removed final access modifiers from API classes


      Added RSServer hook wrapper to get the client's cached list of server/world info


      [NEW] Bug fix for intelligent banking


      [NEW] Improvement to the stability of LG over time


      [NEW] Vastly improved the reliability and speed of Screen#getColorAt on both LG and the regular client


      [NEW] Fix LG login problems


      [NEW] Fixed re-sizable mode container bug


      [NEW] Fixed re-sizable mode mouse bug


      [NEW] Use of public constants in the Banking API


      [NEW] Use of other various constants such as Projection#NULL_PT and Screen#EMPTY_COLOR



      More features to come very soon!

      Please test it and let us know here if there are any new bugs introduced in this release.
        • Thanks
        • Like
      • 12 replies
    • Try our development release by checking "Development Release" on the TRiBot Loader. Note that these new features are currently in beta.

      This release features:

      Re-sizable mode support for both LG and the regular client


      Slightly improved login bot


      Removed final access modifiers from API classes


      Added RSServer hook wrapper to get the client's cached list of server/world info


      Bug fix for intelligent banking


      Improvement to the stability of LG over time



      More features to come very soon!

      Please test it and let us know here if there are any new bugs introduced in this release.
        • Thanks
        • Like
      • 10 replies
    • - Updated the banking API to use the game item cache instead of interfaces. This will result in less delay, greater efficiency, and greater reliability. LG will especially benefit from this update.
      - Fixed a bug with the Grand Exchange API relating to searching for items.
        • Like
      • 5 replies
    • This release includes:

      * Banking update fix
      * Cache loader bug fix
      ** When TRiBot detects the cache reader has issues loading the cache, it will reload it all. This fixes the problem of loading an old cache which is re-written after loading a new client update.
        • thonking
        • Sad
        • Haha
        • Thanks
        • Like
      • 43 replies
  • Recently Browsing   0 members

    No registered users viewing this page.

×