mitsuki Posted January 23, 2021 Share Posted January 23, 2021 Can I use multiple classes for a script? What I essentially want to do it do a task until a condition is met, and then perform a different task, within a different java class in the same script. is this possible? and if so, how do I switch to the next class within my code? Sorry about the question, i'm a java noob xD Quote Link to comment Share on other sites More sharing options...
ProjectPact Posted January 23, 2021 Share Posted January 23, 2021 You should try Script Factory Quote Link to comment Share on other sites More sharing options...
mitsuki Posted January 23, 2021 Author Share Posted January 23, 2021 3 minutes ago, ProjectPact said: You should try Script Factory I already own script factory, I'm trying to start writing my own scripts properly. Just wondering if what I asked was possible, that's all Quote Link to comment Share on other sites More sharing options...
Gunman Posted January 23, 2021 Share Posted January 23, 2021 Money hungry Project didn't answer the question. Answer is yes you can. Read everything in OOP 1 & 2 and I think that would be enough to start messing around with multiple classes. EDIT: Forgot to link the material https://www.programiz.com/java-programming 2 Quote Link to comment Share on other sites More sharing options...
mitsuki Posted January 23, 2021 Author Share Posted January 23, 2021 8 minutes ago, Gunman said: Money hungry Project didn't answer the question. Answer is yes you can. Read everything in OOP 1 & 2 and I think that would be enough to start messing around with multiple classes. EDIT: Forgot to link the material https://www.programiz.com/java-programming Thank you dude! Quote Link to comment Share on other sites More sharing options...
mitsuki Posted January 24, 2021 Author Share Posted January 24, 2021 for osbot, would I use one class to control the script, and use the onLoop methods from the other classes? Quote Link to comment Share on other sites More sharing options...
Nbacon Posted January 24, 2021 Share Posted January 24, 2021 (edited) heres the 2 ways to do mutiple classes. I know there are more but these are simple. Type 1: public class Something extends MethodProvider { public void doSomething(){ getBank().Open() } } in your main script do this Something something = new Something() void onStart(){ something.exchangeContext(getBot()); } Type 2: public class Something{ MethodProvider mp; public Something(MethodProvider mp){ this.mp =mp } public void doSomething(){ mp.getBank().Open() } } REad your question wrong this is something you like Just warning scripts write like this are hard to debug and pron to errors import org.osbot.rs07.script.MethodProvider; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; public abstract class Test extends MethodProvider { abstract void doSomething(); abstract boolean done(); abstract Test next(); } public class OpenBank extends Test { @Override void doSomething() { try { this.getBank().open(); } catch (InterruptedException e) { e.printStackTrace(); } } @Override boolean done() { return getBank().isOpen(); } @Override Test next() { return new CloseBank(); } } public class CloseBank extends Test { @Override void doSomething() { this.getBank().close(); } @Override boolean done() { return !getBank().isOpen(); } @Override Test next() { return new OpenBank(); } } @ScriptManifest(author = "Bacon", name = "0", info = "Runtime bots", version = 0.0, logo = "") public class ScriptWithtasks extends Script { Test curent = new OpenBank(); @Override public void onStart() throws InterruptedException { curent.exchangeContext(getBot()); } @Override public int onLoop() throws InterruptedException { curent.doSomething(); if (curent.done()){ curent = curent.next(); curent.exchangeContext(getBot()); } return 0; } } Irl ProjectPact be like... Random person: Someone call 911. ProjectPact: You should try Script Factory Edited January 24, 2021 by Nbacon 1 Quote Link to comment Share on other sites More sharing options...
ProjectPact Posted January 24, 2021 Share Posted January 24, 2021 4 hours ago, Gunman said: Money hungry Project didn't answer the question. Answer is yes you can. Read everything in OOP 1 & 2 and I think that would be enough to start messing around with multiple classes. EDIT: Forgot to link the material https://www.programiz.com/java-programming Or trying to help someone with a tool that is designed to develop scripts with no programming knowledge. Quote Link to comment Share on other sites More sharing options...
ProjectPact Posted January 24, 2021 Share Posted January 24, 2021 47 minutes ago, Malcolm said: But learning Java is more fulfilling Biden himself has spoken. 1 Quote Link to comment Share on other sites More sharing options...