Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (â‹®) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Pass Area variable to method

Featured Replies

I apologize for asking another question so quickly.

I want to create a reusable method for webwalking so I don't have to keep typing it out. Basically I want to do this:

 

private void walk() {

             if (!x.contains(myPosition())) {
            getWalking().webWalk(x);
            Sleep.sleepUntil(() -> x.contains(myPosition()), 2000);
            sleep(random(100, 500));
}

And I want to be able to call the method by doing

walk(x);

Somewhere in the script. So that I could change x to a different area, like "walk(cowArea);" or "walk(giantArea);" whenever I need. I know this is easy but it's kicking my ass.

6 minutes ago, bumzag said:

I apologize for asking another question so quickly.

I want to create a reusable method for webwalking so I don't have to keep typing it out. Basically I want to do this:

 

private void walk() {

             if (!x.contains(myPosition())) {
            getWalking().webWalk(x);
            Sleep.sleepUntil(() -> x.contains(myPosition()), 2000);
            sleep(random(100, 500));
}

And I want to be able to call the method by doing

walk(x);

Somewhere in the script. So that I could change x to a different area, like "walk(cowArea);" or "walk(giantArea);" whenever I need. I know this is easy but it's kicking my ass.

No need to worry about asking too many questions. That's how you learn 🙂 

You are just missing the parameter for the method. A parameter is placed in between the parenthesis after your method name, so it would look like this walk(Area x)

In code. Also you don't need to use a sleep as the WebWalker will pause further execution of the script until the event is over.

private void walk(Area x) {
    if (!x.contains(myPosition())){
        getWalking().webWalk(x);
    }
}
  • Author
6 minutes ago, BravoTaco said:

No need to worry about asking too many questions. That's how you learn 🙂 

You are just missing the parameter for the method. A parameter is placed in between the parenthesis after your method name, so it would look like this walk(Area x)

In code. Also you don't need to use a sleep as the WebWalker will pause further execution of the script until the event is over.


private void walk(Area x) {
    if (!x.contains(myPosition())){
        getWalking().webWalk(x);
    }
}

Awesome thanks man, that works. I had it set up like that but I didn't know the x was interchangeable. The x is just a placeholder and can be changed out with anything right?  Like I could do 

private void walk(Area flippityFloppityFloomSham) {

    if(!flippityFloppityFloomSham.contains(myPositions())){

        getWalking().webWalk(flippityFloppityFloomSham);

    }

}

 

And it would work the same, right? Thanks again

4 minutes ago, bumzag said:

Awesome thanks man, that works. I had it set up like that but I didn't know the x was interchangeable. The x is just a placeholder and can be changed out with anything right?  Like I could do 

private void walk(Area flippityFloppityFloomSham) {

    if(!flippityFloppityFloomSham.contains(myPositions())){

        getWalking().webWalk(flippityFloppityFloomSham);

    }

}

 

And it would work the same, right? Thanks again

Yeah exactly, the parameter name does not matter. Only the type, in this case Area, does.

Edited by BravoTaco

  • Author
1 minute ago, BravoTaco said:

Yeah exactly, the parameter name does not matter. Only the type, in this case Area, does.

Makes so much more sense. Thank you!

1 minute ago, bumzag said:

Makes so much more sense. Thank you!

Np, feel free to PM me if you have any questions.

I'm glad to see that @BravoTaco could help you out.

However, I would like to point out that it is highly advised to first learn the fundamentals of Java and OOP (Object-oriented programming) before diving into developing scripts. 

Although you're always free to ask questions, a question is never 'dumb', it is obvious that you do not master the fundamentals and that you'll make it a lot harder for yourself by not properly learning fundamentals in the beginning.

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.