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
  • First Script: Edgeville Men Killer


    Recommended Posts

    Posted (edited)

    https://github.com/jamesjang/EdgevilleMen/tree/main

     

    This is my first script using Dreambot's API & in Java. 

    I'm a c++ guy working in the game dev scene and this is all new to me. I know I did a lot of things wrong and want to continue improving so any tips and reference materials would be awesome. I made this referencing the free scripts that are available here. Created it because I just wanted to train my personal account so there are no configs available. Also didn't know how to make global vars? 

     

    Thanks

    Edited by javanotreal
    link
    Link to comment
    Share on other sites

    C# .NET guy here

    this is how i make global vars:

     

    package Settings;
    
    
    import org.dreambot.api.methods.map.Area;
    
    public class ScriptSettings {
    
        public static final ScriptSettings scriptSettings = new ScriptSettings();
        public static ScriptSettings getSettings() {
            return scriptSettings;
        }
    
        public int radius = 5;
    
        public boolean shouldLoop = true;
        public boolean shouldFletch = true;
        public boolean shouldDrop = false;
        public boolean shouldFiremake = false;
        public boolean shouldUseStartTile = true;
        public boolean isDeveloperMode = false;
    
        public Area startArea = new Area();
    
    }

    then I just call getSettings()


     

    Quote

     I know I did a lot of things wrong and want to continue improving so any tips and reference materials would be awesome

    For heavy duty scripts I enjoy tree branch framework, I write all my scripts with that layout instead of AbstractScripts

    here are some resources I used: 

    https://github.com/inubot-scripters/doga-sandstone-miner
    https://github.com/rroarings/dreambot_scripts

     

    And in general just look here for good tips


    https://github.com/search?q=dreambot+language%3AJava&type=repositories&l=Java&s=updated&o=desc

    Link to comment
    Share on other sites

    Posted (edited)
    29 minutes ago, Luxe said:

    C# .NET guy here

    this is how i make global vars:

     

    package Settings;
    
    
    import org.dreambot.api.methods.map.Area;
    
    public class ScriptSettings {
    
        public static final ScriptSettings scriptSettings = new ScriptSettings();
        public static ScriptSettings getSettings() {
            return scriptSettings;
        }
    
        public int radius = 5;
    
        public boolean shouldLoop = true;
        public boolean shouldFletch = true;
        public boolean shouldDrop = false;
        public boolean shouldFiremake = false;
        public boolean shouldUseStartTile = true;
        public boolean isDeveloperMode = false;
    
        public Area startArea = new Area();
    
    }

    then I just call getSettings()


     

    For heavy duty scripts I enjoy tree branch framework, I write all my scripts with that layout instead of AbstractScripts

    here are some resources I used: 

    https://github.com/inubot-scripters/doga-sandstone-miner
    https://github.com/rroarings/dreambot_scripts

     

    And in general just look here for good tips


    https://github.com/search?q=dreambot+language%3AJava&type=repositories&l=Java&s=updated&o=desc

     

     

    Thank you so much for this! Will definitely give those repos a view and implement some of the ideas in my next script. 

    The tree branch framework does look interesting and will give it a look. Thanks man!

    Edited by javanotreal
    Link to comment
    Share on other sites

    What's the advantage of following the Singleton pattern instead of just making every variable in ScriptSettings static?

    Link to comment
    Share on other sites

    @javanotreal Not that I'm very good myself:

    Instead of checking if the bank / inventory is open and then opening it, you can just:

    if (Bank.open()) { // Opens the bank if it isnt already

         // Do your bank stuff

    }

    In your onLoop() you return 0. So it doesn't wait at all before looping again. I wonder if your script is uses a lot of CPU because of this (when its not doing a sleepUntil).

    You might simplify things by using guard breaks instead of sleepUntil everywhere.

    onLoop() {

        if (condition to bank) {

              // bank

              return 1000;

        }

        if (condition to cut wood) {

            // cut wood

            return 1000;

        }

    }

    Link to comment
    Share on other sites

    2 hours ago, coff said:

    What's the advantage of following the Singleton pattern instead of just making every variable in ScriptSettings static?

    I have no clue how lifetime variables work in java, this was what i gathered from other scripts on github as well as talking with mr. GPT. I have used it in about 10 scripts and i think this method works fine. I have never tried static variables.

    Link to comment
    Share on other sites

    11 hours ago, javanotreal said:

    working in the game dev scene

    Your project structure is screaming game dev. Good flash back to when I was coding in unreal engine. I should get back into it, it was fun.

    Everyone else already covered the big stuff, so I'll just leave you with one comment. Your case convention is off. This is pretty irrelevant in regards to your code's functionality but it can help readability if you follow standard case conventions:
    image.png.e807a8926141624d69ae4c75a0a9ef6b.png

    For more, see: https://www.oracle.com/java/technologies/javase/codeconventions-namingconventions.html

    This way, if you ever come back to your code or share it with someone else, you can more easily tell what is a constant, method, variable, class, etc. just at a glance.

    Link to comment
    Share on other sites

     

    3 hours ago, morten1ela said:

    Your project structure is screaming game dev. Good flash back to when I was coding in unreal engine. I should get back into it, it was fun.

    Everyone else already covered the big stuff, so I'll just leave you with one comment. Your case convention is off. This is pretty irrelevant in regards to your code's functionality but it can help readability if you follow standard case conventions:
    image.png.e807a8926141624d69ae4c75a0a9ef6b.png

    For more, see: https://www.oracle.com/java/technologies/javase/codeconventions-namingconventions.html

    This way, if you ever come back to your code or share it with someone else, you can more easily tell what is a constant, method, variable, class, etc. just at a glance.

    It's great to see a fellow game developer here! I worked with Unreal since udk days but now a days I'm working with blizzard's in house engine haha. Thank you for letting me know about the naming conventions. 

     

    10 hours ago, coff said:

    @javanotreal Not that I'm very good myself:

    Instead of checking if the bank / inventory is open and then opening it, you can just:

    if (Bank.open()) { // Opens the bank if it isnt already

         // Do your bank stuff

    }

    In your onLoop() you return 0. So it doesn't wait at all before looping again. I wonder if your script is uses a lot of CPU because of this (when its not doing a sleepUntil).

    You might simplify things by using guard breaks instead of sleepUntil everywhere.

    onLoop() {

        if (condition to bank) {

              // bank

              return 1000;

        }

        if (condition to cut wood) {

            // cut wood

            return 1000;

        }

    }

     

    Thank you about this. I wasn't actually sure about what to return in the loop but it makes more sense now. Time to search what a guard break is. 

    Link to comment
    Share on other sites

    I had a couple hours free at work and made my second script (as I wasn't getting any exp at men).

    I didn't have a lot of time so it was rushed but I wanted to post an update as I feel like a lot has changed in a span of a day haha. I have a few ideas I wanted to implement but the only time I get to work on this is lunch breaks and before work :(

     

    Link to comment
    Share on other sites

    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
    ×
    ×
    • 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.