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
  • import org.dreambot.api.utilities.Sleep; Not working has it been changed or is my dreambot just not working as intended?


    Recommended Posts

    Posted

    Trying something very simple to learn/get into it Here is my code

     

    import org.dreambot.api.methods.container.impl.Inventory;
    import org.dreambot.api.methods.interactive.GameObjects;
    import org.dreambot.api.methods.interactive.Players;
    import org.dreambot.api.methods.map.Area;
    import org.dreambot.api.methods.walking.impl.Walking;
    import org.dreambot.api.script.AbstractScript;
    import org.dreambot.api.script.Category;
    import org.dreambot.api.script.ScriptManifest;
    import org.dreambot.api.utilities.Logger;
    import org.dreambot.api.wrappers.interactive.GameObject;
    import org.dreambot.api.utilities.Sleep;
    
    @ScriptManifest(name = "Woodcutter", description = "Cuts trees until inventory is full", author = "Your Name",
            version = 1.0, category = Category.WOODCUTTING, image = "")
    public class TestClass extends AbstractScript {
    
        private final Area WOODCUTTING_AREA = new Area(3151, 3449, 3174, 3463); // Tree chopping area
    
        @Override
        public int onLoop() {
            Logger.log("Initiating WoodChopper");
    
            if (Inventory.isFull()) {
                Logger.log("Inventory full, stopping script.");
                stop(); 
                return 1000;
            }
    
            if (!WOODCUTTING_AREA.contains(Players.getLocal())) {
                Logger.log("Walking to woodcutting area...");
                Walking.walk(WOODCUTTING_AREA.getRandomTile());
                sleep(2000, 3000);
                return 1000;
            }
    
            GameObject tree = GameObjects.closest(t -> t.getName().equalsIgnoreCase("tree")); // Looks for a regular tree
            if (tree != null && tree.interact("Chop down")) {
                Logger.log("Chopping tree...");
                Sleep.sleepUntil(() -> Players.getLocal().isAnimating(), 3000);
                Sleep.sleepUntil((() -> !tree.exists() || !Players.getLocal().isAnimating()), 10000); 
            } else {
                Logger.log("No tree found, waiting...");
                sleep(500);
            }
    
            return 1000; 
        }
    }
    Posted
    7 hours ago, oogieboogie said:

    try

    Sleep.sleep(<integer>);

    The problem is that it doesnt find the module Sleep I cant import it. I have made my own cutsom sleep for now but I dont get why its not working / importing

    Posted (edited)

    your doing alot of sleep() which is hardcoded sleeps & also not dreambots (Sleep) , best todo Sleep.sleepuntil not hardcoded sleeps.

    import org.dreambot.api.utilities.Sleep;

    Sleep.sleepUntil(() -> !Players.getLocal().isMoving(), 5000); //example of sleeping until the player is idle

    Sleep.sleepUntil(() -> !Bank.isOpen(), 2000); //sleep until bank is closed 


    you can use sleepuntil() to get far more dynamic sleeps . 

    aslong as you got your IDE setup correctly sleep should work fine for you

    Edited by Gimpy Gold
    Posted
    2 hours ago, Gimpy Gold said:

    your doing alot of sleep() which is hardcoded sleeps & also not dreambots (Sleep) , best todo Sleep.sleepuntil not hardcoded sleeps.

    import org.dreambot.api.utilities.Sleep;

    Sleep.sleepUntil(() -> !Players.getLocal().isMoving(), 5000); //example of sleeping until the player is idle

    Sleep.sleepUntil(() -> !Bank.isOpen(), 2000); //sleep until bank is closed 


    you can use sleepuntil() to get far more dynamic sleeps . 

    aslong as you got your IDE setup correctly sleep should work fine for you

    Thanks I will look to implement this but it still isnt finding Sleep within the utilities class I suppose I may need to reinstall dreambot and see if that fixes it

    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.