Batko 0 Share Posted October 6, 2019 Hi, Assume you have two scripts, e.g., a Woodcutting and a Mining script. Is it possible to write another class which uses these given however you want it? I've read around the API and it seems that it is possible, however, I'm unsure where to start. Example: @ScriptManifest(author = "You", name = "Selector", version = 1.0, description = "Execute script orders", category = Category.WOODCUTTING) public class Selector extends AbstractScript { public void onStart() { log("Starting up"); } public void onExit() { log("Closing down."); } @Override public int onLoop() { //1: Run WC script until custom termination //2: Run Mining script until custom termination //Kill the selector script return -1; } } The reason I want to do this is that it leaves modularity to the original scripts since they can run stand-alone, but also provide flexibility to run from a main controlling script. Link to comment Share on other sites More sharing options...
yeeter 520 Share Posted October 6, 2019 I personally just abuse quickstart to do this but there is probably a better way to do it I just call a new client instance while logging out with the new selected script. Link to comment Share on other sites More sharing options...
Batko 0 Author Share Posted October 6, 2019 Sure, but this still forces you to manually start each script, unless you program a bash script to run send your command line arguments. Link to comment Share on other sites More sharing options...
Batko 0 Author Share Posted October 6, 2019 Just figured out it is possible to start the other script through ScriptManager mg = new ScriptManager(getClient().getInstance()); LocalLoader ll = new LocalLoader(); for (java.lang.Class<? extends AbstractScript> script : LocalLoader.getScripts()) { if (script.getName().equalsIgnoreCase("Woodcutter")) { mg.start(script); } } where this loops through the local scripts and find the specified script name to start. However, my next question is how to pass any arguments while starting it this way? Assuming the onStart method has been overridden to accept arguments. Link to comment Share on other sites More sharing options...
Batko 0 Author Share Posted October 6, 2019 Continuing on the answer above, I've figured out that the API should be able to take in arguments in the following way mg.start("test1", "arg1","arg2","arg3"); it compiles, runs, and starts the other script, however, the onStart method doesn't recognise the arguments I'm passing. Anyone else had this problem? Is it perhaps because I'm not VIP yet, and command line arguments/ starting scripts with arguments is for VIP and higher users? Link to comment Share on other sites More sharing options...
Roma 2221 Share Posted October 6, 2019 56 minutes ago, Batko said: Continuing on the answer above, I've figured out that the API should be able to take in arguments in the following way mg.start("test1", "arg1","arg2","arg3"); it compiles, runs, and starts the other script, however, the onStart method doesn't recognise the arguments I'm passing. Anyone else had this problem? Is it perhaps because I'm not VIP yet, and command line arguments/ starting scripts with arguments is for VIP and higher users? List<Class<? extends AbstractScript>> localScripts = LocalLoader.getScripts(); Find the script by name and simply call the onStart method. script.onStart(args) ... loop ... script.onExit() And yes, I believe that quickstart is a VIP feature. Link to comment Share on other sites More sharing options...
ezgpez 0 Share Posted October 11, 2019 On 10/6/2019 at 6:50 PM, Roma said: loop Do you have to loop manually or is it triggered when you call onStart method? Link to comment Share on other sites More sharing options...
Nuclear Nezz 2051 Share Posted October 11, 2019 If you're running a script inside of a script, you'll want to call the internal script's loop in your main script's onLoop Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.