SXForce Posted May 19, 2013 Share Posted May 19, 2013 (edited) I am trying to create a larger script than usual, so I want to use multiple files for it. Now I have the main script that starts up, but I have to use the methods of "MethodProvider" in the OSBot API in the other class too. Something like: MainScript.java private DoWalkPath path; @Override public void onStart() { path = new DoWalkPath(); // This is just an example name, I don't want the other class just to walk... } @Override public int onLoop() throws InterruptedException { switch (state) { case WALKING_TO_BANK: path.walk(); // This is what I want break; } return 3; } DoWalkPath.java public void walk() { openTab(Tabs.Magic); selectInterfaceOption(271, 23, "Cast"); // Teleport or something sleep(random(5000, 6000)); // Wait for teleport walk(Position); // Walk from there } Now I can't use "walk()" as I don't have access to the MethodProvider in that other class. I tried extending the MethodProvider, but I every value is null (client etc). Edited May 19, 2013 by SXForce Link to comment Share on other sites More sharing options...
Wizard Posted May 19, 2013 Share Posted May 19, 2013 You have to pass object that uses Method provider, Script class extends it so you can use it. Make a constructor in you DoWalkPath class which takes Script as a parameter something like this public DoWalkPath(Script script) { this.script = script; } and to initiate it in the main calss just simplu make an DoWalkPath and pass to it the parameter script(Main class) public DoWalkPath walk = new DoWalkPath(this); Hope this helps. Link to comment Share on other sites More sharing options...
SXForce Posted May 19, 2013 Author Share Posted May 19, 2013 You have to pass object that uses Method provider, Script class extends it so you can use it. Make a constructor in you DoWalkPath class which takes Script as a parameter something like this public DoWalkPath(Script script) { this.script = script; } and to initiate it in the main calss just simplu make an DoWalkPath and pass to it the parameter script(Main class) public DoWalkPath walk = new DoWalkPath(this); Hope this helps. Yeah, just did this and it works. Thanks for the answer. Isn't there another way where i dont have to pass the entire class? :P Link to comment Share on other sites More sharing options...
Wizard Posted May 19, 2013 Share Posted May 19, 2013 Not really, after all you have to pass the class or the methods with throw NPE Link to comment Share on other sites More sharing options...
danieljvdm Posted May 19, 2013 Share Posted May 19, 2013 You could try extend your main class as a super class and then you can use all of those methods... Link to comment Share on other sites More sharing options...