Jump to content

Welcome to DreamBot!

Download for Free

Supercharge Your Bots

Run unlimited bots today using DreamBot's Covert Mode and
stay more protected.

Upgrade Now
Frequently Asked Questions
  • Are you not able to open the client? Make sure you have Java 8 installed
  • 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 gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
OSRS Gambling

Interested in advertising your business? Reach out today!

Download the DreamBot client today!
DtohhM8

Scriping Wrapper - Easy set-up to start Scripting

Recommended Posts

DREAMBOT EASY | SCRIPTING FRAMEWORK

SCRIPTING MADE EASY

Current Status: Has Inheritance Issues - Will Release updated fix soon. (NOT WORKING)

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Please excuse the layout - the spoilers will not seem to work.

Open the first one to read the contents.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

What is it:

 

 

 

DBE is a wrapper for any Script using Dreambot. It allows for precise maintainability in code and OOP approaches.

Its flexibility allows you to create ideas and reuse ideas by implementing them as libraries. For example, you could write a banking library and use it in any script.

Libraries gain direct up-to-date data from the API by using the getProvider() method, giving you the ability to cross thread.

 

Why use it:

 

 

 

The wrapper is designed to build an easy to use environment for your Scripts. With an OOP approach so you can build functionality in Libraries to re-use at a later date, the Wrapper is perfect for beginners who are learning to code and for experts who want to re-use content across the board making development simple.

 

How to download it and set it up:

 

 

 

You can download it via GitHub. Simply clone and download it or follow the README for VCS.

 

Tutorial on how to create a simple walking library:

 

 

 

Start by creating a new Class and calling it Walker inside of the `dreambot.libs` package.

package dreambot.libs;

import org.dreambot.api.methods.map.Area;
import org.dreambot.api.methods.map.Tile;
import org.dreambot.api.wrappers.interactive.NPC;

public class Walker extends Library {
    private int lenOfTime = 6000 * 60; // 1 Hour to walk to the Location

    public void walkTo(Tile t) {
        // This only walks to the next point in the WebWalker
        // So we'll have to loop this in the Script until playerIsAtTile() or playerIsInArea()
        // Depending on how exact you want it to be
        getProvider().getWalking().walk(t);
        getProvider().sleepUntil(() -> !getProvider().getLocalPlayer().isMoving(), lenOfTime);
    }

    public boolean playerIsAtTile(Tile t) {
        return getProvider().getLocalPlayer().getTile().equals(t);
    }

    public boolean playerIsInArea(Area a, Tile t) {
        return a.contains(getProvider().getLocalPlayer().getTile()) && getProvider().getLocalPlayer().getTile().distance(t) <= 20;
    }
}

Navigate to your `dreambot.main` package and open the Main Class. Search for and append your new Library:

public ArrayList<Class<? extends Library>> libs = new ArrayList<>(Arrays.asList(
	Walker.class,
));

Navigate, in the same package, to your Script class. Here we will add the logic for our Script to walk to a location.

public class Script extends Provider {

	Walker walkerLib; // Create a local variable for our Library

    public Script(Main provider) {
        super(provider);
    }

    @Override
    public void onStart() {
        // Instance and store the library
		walkerLib = getProvider().getLibInstance(Walker.class);
		// getProvider() allows us to get the Main class
		// getLibInstance() allows us to get any lib inside our libs array
    }

    @Override
    public int onLoop() {
    	// Add your own x,y,z values
		if(! walkerLib.playerIsAtTile(new Tile(x, y, z)) {
			// The walkTo method will walk to a WebWalker tile each loop
			// We wrap it in an If statement because it will talk multiple loops to walk to the location
			walkerLib.walkTo(new Tile(x, y, z));
		}

        // Return a short delay
        return Calculations.random(100, 300);
    }

    @Override
    public void onExit() {

    }
}

 

 

If you experience any bugs, or want to offer any improvements or update ideas: please leave a comment below.

Happy Scripting.

 

 

 

 

Edited by DtohhM8
Added layout issue heading

Share this post


Link to post
Share on other sites

Didn't dig completely into it, but from what I did see, looks like good packaging, naming, formatting and commenting through-out. Readability is nice and clean. I can see people using this in the future as a base. Good job.

Share this post


Link to post
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.

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.


×
×
  • Create New...