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

    Recommended Posts

    Posted

    Hello,

    I have been experimenting with the API over the last few weeks.  Here is a script I have been running on a few accounts for the last week or so, slowly improving it to a point where I'm not ashamed to share it with the world :)

    It is a script that shears sheep in lumbridge. Can start anywhere as long as shears are in the inventory.

    Looking for any critique on my usage of the API, especially around making sure actions are successful and handling unexpected events. Apologies if my syntax/casing is off, I develop in another language by trade and sometimes my brain autopilots into that.

    https://github.com/Evin007/Dreambot-Scripts/blob/master/SheepShearer/src/SheepShearer.java

    Posted

    Hey there, I took a quick look and here's a few thing I noticed:

    1) You seem to be manually handling staircases to walk to places, this generally isn't necessary as our walker can handle many things on its own, you just need to call Walking#walk to the final tile.

    2) I would avoid looping like you do in your Walker class (actually any loops based on any in game state for the most part), or at least add a few breakouts if you can't path to an area or if you disconnect, etc.

    3) Setting initial state in your onStart won't work correctly if you start it logged out, not sure if the script could gracefully recover from that without looking at it more.

    A few other minor things like formatting/indentation, but overall it looks like a good start, great job :)

    Posted

    Thanks, did not know the walker could handle going up/down stairs, neat!

    Is the general use case of holding script execution until the client has logged you in just to wait on Client.isLoggedIn() ?

    Posted

    It can do quite a bit more than just staircases, we support most teleports in the game, fairy rings, spirit trees, and other stuff like that if you have the available equipment or items.

    Our solvers should deal with logging in, so usually in your onLoop you should be logged in, although on script start sometimes it may start before we're done. If you want to be 100% certain, just check at the start of your onLoop and return if you're not logged in yet.

    Posted

    This

    Sleep.sleepUntil(() -> Inventory.count("Wool") > woolCount, 3000);

    will sleep for maximum 3 seconds and then possibly click the sheep again. If the sheep is far and you have no run energy, you'll very likely end up clicking the sheep a second time.

    Extend the above sleep with

    Sleep.sleepUntil(() -> Inventory.count("Wool") > woolCount, () -> Players.getLocal().isMoving(), 3000, 100);

    and your sleep will reset its timer when the player is moving. This way the script will sleep until you obtain wool or you haven't moved in 3 seconds.

    More info: https://dreambot.org/javadocs/org/dreambot/api/utilities/Sleep.html

    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.