October 22, 20169 yr 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);
October 22, 20169 yr 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, 20169 yr by Explv
October 22, 20169 yr Author 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?
October 22, 20169 yr 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, 20169 yr by Solzhenitsyn
October 24, 20169 yr 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, 20169 yr by Explv
October 29, 20169 yr 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. }
October 30, 20169 yr 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.
Create an account or sign in to comment