Expels Posted October 22, 2016 Share Posted October 22, 2016 If I were to use the following code in my onLoop it uses a lot of CPU, what would be a better option? new ChopTrees(this); Quote Link to comment Share on other sites More sharing options...
Explv Posted October 22, 2016 Share Posted October 22, 2016 (edited) If I were to use the following code in my onLoop it uses a lot of CPU, what would be a better option? new ChopTrees(this); Create it in onStart and store it globally.I assume you have all your chopping code in the constructor, move it into a separate method and call that on the created object: chopTreesObj.chop(); Edited October 22, 2016 by Explv Quote Link to comment Share on other sites More sharing options...
Expels Posted October 22, 2016 Author Share Posted October 22, 2016 Create it in onStart and store it globally. I assume you have all your chopping code in the constructor, move it into a separate method and call that on the created object: chopTreesObj.chop(); Okay, so I have this in a separate class (file) and in my onStart: public class ChopTrees { public void chopTrees(Script sI) { public void onStart() { new ChopTrees(); What now? Quote Link to comment Share on other sites More sharing options...
Solzhenitsyn Posted October 22, 2016 Share Posted October 22, 2016 (edited) ChopTrees a; // Create in parent frame onStart() { a = new ChopTrees(this) // Initialize in onStart } onLoop() { a.<...> // Access in onLoop } Edit: If you have no idea what's going on Edited October 22, 2016 by Solzhenitsyn 3 Quote Link to comment Share on other sites More sharing options...
Explv Posted October 24, 2016 Share Posted October 24, 2016 (edited) Okay, so I have this in a separate class (file) and in my onStart: public class ChopTrees { public void chopTrees(Script sI) { public void onStart() { new ChopTrees(); What now? I recommend you follow some Java tutorials before trying to write scripts: https://www.tutorialspoint.com/java/java_object_classes.htm Edited October 24, 2016 by Explv 2 Quote Link to comment Share on other sites More sharing options...
TheGreatests Posted October 29, 2016 Share Posted October 29, 2016 Could do this, as this is what I do when I call methods from a different class public class main extends Script { Classname m = new classname(); onstart(){ You can call it in the onstart class by doing this m.(whatever method you are gonna use from the other class) } or you could call it on your onloop, or instead your switches. } Quote Link to comment Share on other sites More sharing options...
Alek Posted October 30, 2016 Share Posted October 30, 2016 Learn how to code before you copy-pasta task node systems. Also why the hell are you passing script and not the Bot instance? Edit2: I deleted that tutorial Too many new scripters are using those node frameworks without understanding them. There is nothing wrong with using the simple loop until you understand OOP. Once you learn more about Java, you will be able to write and understand that node system. For now, just stick with learning step by step. 2 Quote Link to comment Share on other sites More sharing options...