Terri_Farms 0 Posted July 9, 2020 Hi All, I've been trying to write a script that is able to launch other scripts using the ScriptManager.start function. My current code has it starting the other script, but I want to be able to pass parameters to this newly launched script. This is the current code used to launch the new script: ScriptManager mg = new ScriptManager(getClient().getInstance()); mg.start("IronMiner", "args", "test1", "test2"); However, the new script does not seem to receive these arguments and only executes the onStart function that does not take arguments. Any help with this would be appreciated.
TheCloakdOne 389 Posted July 10, 2020 @Override public void onStart(String... params) { log("Started with params: " + params); for (String p : params) { log("Param found: " + p); } super.onStart(params); } does this work for the child script?
Terri_Farms 0 Author Posted July 10, 2020 4 hours ago, thecloakdone said: @Override public void onStart(String... params) { log("Started with params: " + params); for (String p : params) { log("Param found: " + p); } super.onStart(params); } does this work for the child script? When the child script is called it doesn't call the onStart(String... params) method but the normal onStart() method.
Pandemic 2842 Posted July 10, 2020 It''s happening because you're creating your own ScriptManager instead of using the one the client uses. Try starting it through ours (Instance#getScriptManager).
Neffarion 486 Posted July 10, 2020 10 minutes ago, Pandemic said: It''s happening because you're creating your own ScriptManager instead of using the one the client uses. Try starting it through ours (Instance#getScriptManager). Actually, the way he is doing it actually seems to run the script, just without the params. Doing it the way you suggest seems to not even launch it: MethodProvider.log("Starting script"); getClient().getInstance().getScriptManager().start("ScriptName", "Test1", "123param"); MethodProvider.log("Script launched"); However, if you run a script with that code and then try to run the script you want to launch with the params manually, it starts it with the params you set in that code
Terri_Farms 0 Author Posted July 11, 2020 16 hours ago, Pandemic said: It''s happening because you're creating your own ScriptManager instead of using the one the client uses. Try starting it through ours (Instance#getScriptManager). I've just tried using the client's ScriptManager: getClient().getInstance().getScriptManager().start("IronMiner", "params", "test1", "test2"); But this doesn't launch the new script at all.
Neffarion 486 Posted July 11, 2020 3 hours ago, Terri_Farms said: I've just tried using the client's ScriptManager: getClient().getInstance().getScriptManager().start("IronMiner", "params", "test1", "test2"); But this doesn't launch the new script at all. You can use this code (its ugly and fucking weird but it will work) MethodProvider.log("Starting script"); String scriptName = "ScriptName"; String[] scriptParams = new String[] {"param1", "param2"}; getClient().getInstance().getScriptManager().start(scriptName, scriptParams); ScriptManager m = new ScriptManager(getClient().getInstance()); m.start(scriptName, scriptParams); MethodProvider.log("Script launched");
Pandemic 2842 Posted July 11, 2020 Yeah it won't start a script with one already running (the one calling it), it's another reason why you'll have to hack around to do it (like Neff suggests above). We currently don't have an official way to handle it, but I'll look into it for something we could do in DB3.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.