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
  • Tutorial Request:Arrays, this.


    hitsuu

    Recommended Posts

    Hello. I have developed a mining script that banks and returns to mine, but as I don't know how to use arrays, I do not know how to incorporate an array of objects/npcs/items/anything within closest proximity to the playing character, and filtering said objects/npcs/items/anything so that I can include this in a GUI and the individual can select via ID's, which one they want (such as rocks to mine).

     

    I would like someone to create a tutorial on this, please.

     

    Additionally, I'm trying to find out how to use this. and really figure out what it means using the API. I've read up on it in general java use, but it's a whole different game when using it in the API.

     

    Please create this tutorial as well!

     

    best,

    Hitsuu

    Link to comment
    Share on other sites

    Hello. I have developed a mining script that banks and returns to mine, but as I don't know how to use arrays, I do not know how to incorporate an array of objects/npcs/items/anything within closest proximity to the playing character, and filtering said objects/npcs/items/anything so that I can include this in a GUI and the individual can select via ID's, which one they want (such as rocks to mine).

     

    I would like someone to create a tutorial on this, please.

     

    Additionally, I'm trying to find out how to use this. and really figure out what it means using the API. I've read up on it in general java use, but it's a whole different game when using it in the API.

     

    Please create this tutorial as well!

     

    best,

    Hitsuu

     

    My next video tutorial is going to be on how to create a GUI and have it interact with your script. I believe I will simply explain how my open source mining script achieves nearly all of what you want, so it should be of great help.

    Link to comment
    Share on other sites

    My next video tutorial is going to be on how to create a GUI and have it interact with your script. I believe I will simply explain how my open source mining script achieves nearly all of what you want, so it should be of great help.

    ples. Tank u.

    Link to comment
    Share on other sites

    There are some great tutorials on both of these topics all over Youtube, but Ill try to explain "this" quickly to see if I can get you to understand it.

     

    If you've ever done something like:

    Player player  - To create a player object named player

    or

    Item pickaxe   - To create an Item object named pickaxe

     

    With these, you could do something like pickaxe.getName(); to return the name of the item, or use any other method.

     

    You were using objects. Now, the class where all of your script code is (Named whatever you called your script) is also an object. The keyword 'this' is a way for you to specify that you are calling the object that you are currently in.

     

    For example:

    this.player would mean you want the data in the variable "player" that is located in the class that you called 'this' in.

    this.(some method) would use (some method) located in the class you called 'this' in.

    this      (using it alone) would direct to the object of the class itself.

     

     

    Sorry if this isn't very clear, I don't really know how to explain it better without visuals.

    Link to comment
    Share on other sites

    There are some great tutorials on both of these topics all over Youtube, but Ill try to explain "this" quickly to see if I can get you to understand it.

     

    If you've ever done something like:

    Player player  - To create a player object named player

    or

    Item pickaxe   - To create an Item object named pickaxe

     

    With these, you could do something like pickaxe.getName(); to return the name of the item, or use any other method.

     

    You were using objects. Now, the class where all of your script code is (Named whatever you called your script) is also an object. The keyword 'this' is a way for you to specify that you are calling the object that you are currently in.

     

    For example:

    this.player would mean you want the data in the variable "player" that is located in the class that you called 'this' in.

    this.(some method) would use (some method) located in the class you called 'this' in.

    this      (using it alone) would direct to the object of the class itself.

     

     

    Sorry if this isn't very clear, I don't really know how to explain it better without visuals.

    Could you use an example from my script to explain it? Also, can I get your skype in case I have further questions?

    Link to comment
    Share on other sites

    My Skype is xboxnolifes.

     

    I'm not currently familiar with the DreamBot API, but I am fairly good at Java so I may be of help.

     

    I can give you the example if I could see the code. I'm not entire sure were you have it posted.

    Link to comment
    Share on other sites

    public class MyClass{
     

        private String someString = "Hello!";
        public MyClass(String someString){
            //this.someString refers to the current instance of MyClass that you're in, or "Hello!"

            log(this.someString);
            log(someString);//without using this, it refers to the nearest scope of the declaration of someString (in this case, the argument to the method)
        }

    }

     

    main(){
        MyClass mc = new MyClass("Hi!");
    }

     

    in the log would yield

    "Hello!"
    "Hi!"

     

     

    Scope is the general idea of the environment in which a variable exists.

    In Java, the scopes are mostly defined by the {}'s

    if(something){
        int myNewVariable;
    }
    myNewVariable exists only inside of the if statement, the if statement is the scope of myNewVariable's existence

     

    "this" is generally used to distinguish between scopes and instances, mostly only needed when you have a variable declared in smaller scope with the same name as the variable in your class.

    Such as in the instance of the MyClass constructor.

     

    (Feel free for someone to correct me if I messed something up)

     

    As far as Arrays go, you should just look at the java tutorials on Arrays and Lists.

    Link to comment
    Share on other sites

    public class MyClass{

     

        private String someString = "Hello!";

        public MyClass(String someString){

            //this.someString refers to the current instance of MyClass that you're in, or "Hello!"

            log(this.someString);

            log(someString);//without using this, it refers to the nearest scope of the declaration of someString (in this case, the argument to the method)

        }

    }

     

    main(){

        MyClass mc = new MyClass("Hi!");

    }

     

    in the log would yield

    "Hello!"

    "Hi!"

     

     

    Scope is the general idea of the environment in which a variable exists.

    In Java, the scopes are mostly defined by the {}'s

    if(something){

        int myNewVariable;

    }

    myNewVariable exists only inside of the if statement, the if statement is the scope of myNewVariable's existence

     

    "this" is generally used to distinguish between scopes and instances, mostly only needed when you have a variable declared in smaller scope with the same name as the variable in your class.

    Such as in the instance of the MyClass constructor.

     

    (Feel free for someone to correct me if I messed something up)

     

    As far as Arrays go, you should just look at the java tutorials on Arrays and Lists.

    Since posting this thread, I've begun a introductory java course and I have learned about arrays. Thank you for the information.

    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.