Banned2Soon 1 Posted March 18 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; } }
Banned2Soon 1 Author Posted March 18 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
Gimpy Gold 25 Posted March 18 (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 March 18 by Gimpy Gold
Banned2Soon 1 Author Posted March 18 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
Banned2Soon 1 Author Posted March 18 Deleting the client.jar and then reinstalling seemed to do it! oogieboogie 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now