aeikonic Posted March 25, 2021 Share Posted March 25, 2021 (edited) Having an issue where it just crashes the bot. Just trying to get it set up, so there isn't much code, but the gist is like this: import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import skills.Fishing; @ScriptManifest(name = "Testing", author = "Aeikonic", info = "Just a test", version = 0.1, logo = "") public class testBot extends Script { protected Fishing fish; @Override public final int onLoop() throws InterruptedException { fish.goFishing(); return random(150, 200); } } The fishing script is declared like this: public abstract class Fishing extends Script { Is that the issue or is it how I'm calling it in the upper level script? The fishing bot works when turned into a normal script. How do I call it / activate it from another script? EDIT: Updated Fishing to an Event: public class Fishing extends Event { Calling it like this: protected Fishing fish = new Fishing(); @Override public final int onLoop() throws InterruptedException { fish.execute(); return random(150, 200); } Getting a NullPointerException though which says it's at this line: private boolean canFish() { return getInventory().contains("Small fishing net"); } Wasn't getting it when not pulling the script in as an event though, so a bit confused... not sure if I'm still pulling it in wrong or if running it as an event means I need to recode parts of it. EDIT AGAIN: Got it, had to run execute(fish); Edited March 25, 2021 by aeikonic Quote Link to comment Share on other sites More sharing options...
Explv Posted March 26, 2021 Share Posted March 26, 2021 (edited) I'd recommend following some Java tutorials, in your first example you didn't even construct an instance of your Fishing class. You also made your Fishing class abstract, which means it cannot be instantiated directly. Only your main script class should extend Script. If you want other classes to be able to access the API, either pass MethodProvider as a constructor arg, or make your other class extend MethodProvider and exchange context. See section 5 of https://osbot.org/forum/topic/115124-explvs-scripting-101/ Edited March 26, 2021 by Explv Quote Link to comment Share on other sites More sharing options...
aeikonic Posted March 26, 2021 Author Share Posted March 26, 2021 Yeah the IDE was throwing me for a loop because it told me if I didn't have onLoop in Fishing (when it was extending Script) I'd have to make it abstract, which then told me I couldn't instantiate it on the upper level script. Had me all confused but figured it out. Got a few basic scripts working now though Quote Link to comment Share on other sites More sharing options...