Articron Posted April 30, 2013 Share Posted April 30, 2013 Hi, I'm currently making a combat script. I have divided this script into multiple classes, being Combat.java, Walking.java, Main.java, And various other classes. When I create an object from another class, to use it's methods and everything that comes with it, Osbot just gives me the "error with script executor" error thing. Any help? Link to comment Share on other sites More sharing options...
XavierM Posted April 30, 2013 Share Posted April 30, 2013 Didn't understand anything, post the error. Link to comment Share on other sites More sharing options...
Articron Posted April 30, 2013 Author Share Posted April 30, 2013 (edited) Oh, hahaha, I'm sorry, I should've been more clear in my initial post. Anyway, what I'm trying to explain is the following: Snippet from let's say Altar.java: Combat combat; public int onLoop() { try { useItemsonAltar(); activateAltar(); combat.killCow(); } catch (InterruptedException e) { log("nope werkt ni!"); e.printStackTrace(); } return 1; } The method it's refering to in Combat.java: public void killCow() throws InterruptedException { sleep(3000); unicow = closestNPC(UNICOW_ID); if (unicow != null && !unicow.isUnderAttack()) unicow.interact("Attack",true,true); while (client.getClient().getMyPlayer().isUnderAttack()) { log("currently under attack: " + Boolean.toString(client.getClient().getMyPlayer().isUnderAttack())); sleep(5000); } lootHorns(); } It seems that it has trouble trying to call that method from another class, even though I tried a fake constructor, or anything amongst the sorts. My IDE doesn't show up any errors, let alone that I think I made a mistake, OsBot itself just won't execute the killCow method, and will skip it to repeat the onLoop(). Edited April 30, 2013 by Articron Link to comment Share on other sites More sharing options...
XavierM Posted April 30, 2013 Share Posted April 30, 2013 Where's the error? do you initialize that combat variable? add a simple System.out.println("kill cow called"); on killCow method Link to comment Share on other sites More sharing options...
Wizard Posted April 30, 2013 Share Posted April 30, 2013 (edited) Use Script class in the other classes so for example. You main script class is called CombatScript.java and it extends Script. Make a new class called Combat which take a parameter of type Script to be able to use all the script methods it will look something like this: public class Combat { public Combat(Script script) { this.script = script; } public void attack() { script.client..//etc bla bla bla } public Script getScript() { return script; } private Script script;} and In onStart method in your main class you do something like Combat combat = new Combat(this); by this, you passed the script object(your main class) to your combat class and avoid getting null exception now you can call any method of the combat class such as combat.attack(); Hope you understand.. im bad at explaining. if you need anything feel free to ask Edited April 30, 2013 by Wiz Link to comment Share on other sites More sharing options...
Articron Posted April 30, 2013 Author Share Posted April 30, 2013 Ah, Wiz has explained my problem very well! Thanks bro ;) Link to comment Share on other sites More sharing options...