Jump to content

Multiple classes :doge:


Salty as fuck

Recommended Posts

package trumpbitch;

import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

import trumpbitch.Woodcutting;

@ScriptManifest(name = "trumpscape", author = "trump", version = 6.9, info = "trump", logo = "trump")
public class Main extends Script {

    @Override
    public void onStart() {
        // nothing cause trump
    }

    @Override
    public int onLoop() {
        Woodcutting.cutTree(this);
        return 100;
    }

}
package trumpbitch;

import org.osbot.rs07.script.Script;

public class Woodcutting {

    public void cutTree(Script script) {
        script.log("trump for pres");
        // insert just the tip
    }

}

this way is pretty much the same thing but i find it's easier to copy paste to new scripts this way. good luck

 

It's not a good idea to have multiple instances of Script, just keep it a subclass of the Main or if you use Nodes, use your Main's superclass (that certain Script instance) as the Script instance for your other class.

  • Like 1
Link to comment
Share on other sites

Why is it a bad idea? I haven't had an issue with it yet.

 

Script is a type of instance that should only be done once. It's very unlikely to run into problems since we're not dealing with anything that will cause that but think of it this way. When you make a class for methods that needs Script, you're not going to inherit a brand new instance of what your main class has, you want something to 'show' that it's not the main class, hence using the main class' Script instance or using your main class itself.

 

It's 7am and I haven't slept so I may not be explaining it properly, if someone can pitch in that would help. :)

Link to comment
Share on other sites

Script is a type of instance that should only be done once. It's very unlikely to run into problems since we're not dealing with anything that will cause that but think of it this way. When you make a class for methods that needs Script, you're not going to inherit a brand new instance of what your main class has, you want something to 'show' that it's not the main class, hence using the main class' Script instance or using your main class itself.

 

It's 7am and I haven't slept so I may not be explaining it properly, if someone can pitch in that would help. smile.png

 

I thought the method I was using was just using the Script class inherited in the main class (extends Script). The Scripts in the other classes are only used as parameters and aren't other instances?

 

Edited by Shiny
Link to comment
Share on other sites

I thought the method I was using was just using the Script class inherited in the main class (extends Script). The Scripts in the other classes are only used as parameters and aren't other instances?

 

In other classes they're almost always initiated from your main class, for example you have a node that passes a Script parameter.

 

So you do Banking banking = new Banking(this);

 

This refers to the superclass of the class you call it in (the main class) so the superclass is (Script).

 

Am I making sense rn?

Link to comment
Share on other sites

Well, it's a good thing I have this here thread for that there point you're making.

 

And 'one of'.

Saying I know about Java doesn't necessarily imply I can list every single function and know exactly what to do in every situation without outside assistance either.

 

Regardless of what knowledge you have on the topic, you don't understand something until all of the common factors are understood together. Without that, you are literally just putting pieces together, hoping it turns out right.

 

Also, one of my previous posts was intended to expand on information already provided to you. With that being said, I have no reason to insist your level of programming in this case.

Edited by Bitshift
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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