February 14, 20187 yr I have 2 files, main file and another one that I would like imported. Main file code: import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(author = "SirSkitzo", info = "", logo = "", name = "FirstScript", version = 1) public class test extends Script { public void onStart() throws InterruptedException { another a = new another(); a.test(); } public int onLoop() throws InterruptedException { return 0; } } and on the another class import org.osbot.rs07.script.Script; public class another { protected Script script; public another init(Script script){ this.script = script; return this; } public void test() { script.log("A message"); } } It doesn't work and I keep getting errors from the client. What am I doing wrong and how can I fix this? Edited February 14, 20187 yr by sirskitzo
February 14, 20187 yr 2 minutes ago, sirskitzo said: I have 2 files, main file and another one that I would like imported. Main file code: import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(author = "SirSkitzo", info = "", logo = "", name = "FirstScript", version = 1) public class test extends Script { public void onStart() throws InterruptedException { another a = new another(); a.test(); } public int onLoop() throws InterruptedException { return 0; } } and on the another class import org.osbot.rs07.script.Script; public class another { protected Script script; public another init(Script script){ this.script = script; return this; } public void test() { script.log("A message"); } } It doesn't work and I keep getting errors from the client. What am I doing wrong and how can I fix this? You didn't call init?
February 14, 20187 yr Author I thought I already did by another a = new another(); If not how else? @Explv
February 14, 20187 yr pass instance in the constructor of the class another a = new another (instance);
February 14, 20187 yr Author @Chris Sorry for being a noob but I get an error in code now while doing this. Could you please show me how?
February 14, 20187 yr Looks like you are trying to create a task/node system. You should probably just work on your OOP before doing something like this. If you are not working on a task/node system, what are you actually trying to achieve?
February 14, 20187 yr You should probably read up on some OOP principles as Alek said but I'll post a solution. public another init(Script script){ this.script = script; return this; } Change this into a constructor by removing the return type "another". another a = new another(this); pass an instance of your class that extends Script.
February 14, 20187 yr 1 hour ago, Jammer said: You should probably read up on some OOP principles as Alek said but I'll post a solution. public another init(Script script){ this.script = script; return this; } Change this into a constructor by removing the return type "another". another a = new another(this); pass an instance of your class that extends Script. That's not how you define a constructor, the constructor should have the same name as the class. It's not: public init(Script script) { } It's: public another(Script script) { } @sirskitzo you should follow some Java tutorials until you understand the basics.
February 15, 20187 yr 8 hours ago, Explv said: That's not how you define a constructor, the constructor should have the same name as the class. It's not: public init(Script script) { } It's: public another(Script script) { } right, forgot to say that.
Create an account or sign in to comment