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
  • Creating libraries for local development


    BeepBoopBop

    Recommended Posts

    Hey folks,

    I was looking into how to better organize my projects for local script development, and Pandemic pointed me in the direction of Libraries (thank you!). Since there's very little documentation about how to go about doing this, I figured I'd walk through what I did to get it working.

    First, why use libraries? We all probably have some utility classes that we'd like to be available for all of our local scripts. For example, I have "Banker", "Walker", and "Talker" classes. Wouldn't it be great if these were available in all of my projects without having to copy/paste changes to all of my local scripts whenever I make a change? That's what libraries accomplish.

    Here's a list of steps I went through. This is going by memory, so apologies if I miss something crucial.

    1. Create a new DreamBot project. Its title should be the library title (E.g. mine is "BeepLibrary"). It doesn't need a main class, since we're not executing anything!
    2. Move all of your classes to the "Src" folder of this new project. If there are build errors, ensure you've imported the DreamBot library, and included all required classes.
    3. Go into Project Structure for your library project. Set the output directory to the "<Users>\...\DreamBot\Libs" folder.
    4. Build your project. You should see the jar file in the Libs directory.
    5. Open Project Settings for your local script projects. Add a new library - the .jar file you've exported to the Libs folder.
    6. Build your local script. If there are compile errors, you've done something wrong.
    7. You're almost there! In your local script's "src/" folder, create a file named "libs". In that file, the only line of text should be the name of the library you've created in step 1. As an example, my libs file contains "BeepLibrary.jar".
    8. Build your local script. Ensure no compile errors.
    9. Open the script manager. If the local script appears, you're good! Otherwise, open the Console and see if you can figure out where you've gone wrong.

    Happy scripting!

    Link to comment
    Share on other sites

    • 8 months later...

    so  to confirm, this only works for local script development? for example, owning a private script shop then using that project together with the library to reuse that code locally?

    Link to comment
    Share on other sites

    Haven't done much dev over the last two months, but I believe so. SDN doesn't support libraries in separate projects. You'll need to copy/paste the *.java files from your local libraries and include them with your SDN commit.

    Link to comment
    Share on other sites

    • 4 weeks later...
    On 1/21/2023 at 9:03 AM, BeepBoopBop said:

    Haven't done much dev over the last two months, but I believe so. SDN doesn't support libraries in separate projects. You'll need to copy/paste the *.java files from your local libraries and include them with your SDN commit.

    No worries, this is the conclusion I ended up at as well. Thanks!

    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.