bumzag Posted August 31, 2020 Share Posted August 31, 2020 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. Quote Link to comment Share on other sites More sharing options...
BravoTaco Posted August 31, 2020 Share Posted August 31, 2020 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); } } Quote Link to comment Share on other sites More sharing options...
bumzag Posted August 31, 2020 Author Share Posted August 31, 2020 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 Quote Link to comment Share on other sites More sharing options...
BravoTaco Posted August 31, 2020 Share Posted August 31, 2020 (edited) 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, 2020 by BravoTaco Quote Link to comment Share on other sites More sharing options...
bumzag Posted August 31, 2020 Author Share Posted August 31, 2020 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! Quote Link to comment Share on other sites More sharing options...
BravoTaco Posted August 31, 2020 Share Posted August 31, 2020 1 minute ago, bumzag said: Makes so much more sense. Thank you! Np, feel free to PM me if you have any questions. Quote Link to comment Share on other sites More sharing options...
Eagle Scripts Posted August 31, 2020 Share Posted August 31, 2020 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. 2 Quote Link to comment Share on other sites More sharing options...