Jump to content

Calling an Instance in onLoop


Recommended Posts

Posted (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 by Explv
Posted

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?

Posted

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.

 

}

Posted
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. 

  • Like 2

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...