August 31, 20205 yr 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.
August 31, 20205 yr 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); } }
August 31, 20205 yr 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
August 31, 20205 yr 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 August 31, 20205 yr by BravoTaco
August 31, 20205 yr 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!
August 31, 20205 yr 1 minute ago, bumzag said: Makes so much more sense. Thank you! Np, feel free to PM me if you have any questions.
August 31, 20205 yr 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