Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • [Scripting support] How do I make my program utilise multiple Java Classes, and how will an if(x.interact"y") help prevent missclicks?


    Before

    Recommended Posts

     

    put this in your Main class

    private ClasName classname;
    
    
    public void onStart() {
    
    
    classname = new ClasName(this);
    
    
    }

    Then to make a new class

     

    public class ClasName {
    AbstractScript s;
    
    
    public ClasName (AbstractScript ctx) {
    this.s = ctx;
     }
    }

     

     

    Isn't 'this' of the type main (or whatever your main class is called)?  Can you pass this into a class constructor expecting a AbstractScript?

     

    EDIT:  I ask because i'm trying to do this and my IDE complains...

    Link to comment
    Share on other sites

    the key

     

    Isn't 'this' of the type main (or whatever your main class is called)?  Can you pass this into a class constructor expecting a AbstractScript?

     

    EDIT:  I ask because i'm trying to do this and my IDE complains...

    The keyword 'this' means an object of the class in which you use this keyword. If you have your class that extends AbstractScript you can pass 'this' to a constructor of some other object that takes an AbstractScript, as in Diddy's example. If you're getting an error make sure that you have the correct spelling and imports.

    Link to comment
    Share on other sites

    I think what you are looking for is both what Dreamlicker posted and implementing a type of Node framework (there are already a few posts on the forums about that).

     

    If you want a better understanding of how all that works, from a CS standpoint, you might want to look up Polymorphism and Inheritance.

     

    It is also important to understand how Constructor's work when trying to do all of this. 

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.