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

    Recommended Posts

    Posted (edited)

    I have coded my script fine, but my bot just continually walks finding trees, and I would like him to stay within a set boundary.

    I see the constructor:

    Area(XXXX,XXXX,XXXX,XXXX) but how do I implement that in my code?

    How would I say something like

    if bot is in Area(X,X,X,X) then stay;

    else, go back to area
     

    Edited by Taytot
    Posted (edited)
    Area nameOfArea= new Area(x1, y1, x2, y2);


    So an example of one of my own scripts:
     

    private Area houseWaitingArea = new Area(1628, 3111, 1630, 3109);

     

     

    So you could do;
     

    Area nameHere = new Area(1111, 2222, 3333, 4444);
    If (!nameHere.contains(Players.getLocal())) {
    	then xxxx
    }

     

    Edited by KCBot
    Posted

    thanks I used a private final int walk_delay and a check after every action loop to ensure the bot always stays in the zone!

    Posted (edited)
    5 hours ago, Taytot said:

    thanks I used a private final int walk_delay and a check after every action loop to ensure the bot always stays in the zone!

    That works!

    I myself would do this:

    Area nameHere = new Area(1111, 2222, 3333, 4444);
    If (!nameHere.contains(Players.getLocal())) {
    	Walking.walk(nameHere.getRandomTile());
    	sleep(Calculations.random(1000, 4000));
    }
     
    Edited by KCBot
    Posted
    while(!myAreaName.contains(Players.getLocal().getTile())) {
    	Walking.walk(myAreaName.getRandomTile());
    	sleep.sleepUntil(() -> Players.getLocal().isMoving(), Calculations.random(1250,7500));
    }

    like this

    Posted
    9 minutes ago, ImLife said:
    while(!myAreaName.contains(Players.getLocal().getTile())) {
    	Walking.walk(myAreaName.getRandomTile());
    	sleep.sleepUntil(() -> Players.getLocal().isMoving(), Calculations.random(1250,7500));
    }

    like this

    Ideally you don't want to use while loops, specially if you are using taskscript (even if you are not, use states).
    Basically your node would accept if your player is not in myAreaName, with the highest priority.
    Then you only have this in your node:

    Walking.walk(myAreaName.getRandomTile());
    
    sleep.sleepUntil(() -> Players.getLocal().isMoving(), Calculations.random(1250,7500));

     

    Posted
    private final Area treeArea = new Area(X, x, X, X);
    private final int WALK_DELAY = 3000; // Delay between walk check
    private Timer timer;
    
    
    etc etc
    
    
    
    if (!treeArea.contains(Players.getLocal())) {
        walkBackToTreeArea();
        return WALK_DELAY;
     
    Posted
    24 minutes ago, KCBot said:

    Ideally you don't want to use while loops, specially if you are using taskscript (even if you are not, use states).
    Basically your node would accept if your player is not in myAreaName, with the highest priority.
    Then you only have this in your node:

    Walking.walk(myAreaName.getRandomTile());
    
    sleep.sleepUntil(() -> Players.getLocal().isMoving(), Calculations.random(1250,7500));

     

    Ahh thats true. I havent worked too much with anything other than the onLoop architecture.
    But great point!

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