Search the Community
Showing results for tags 'smelting'.
-
import org.dreambot.api.methods.interactive.GameObjects; import org.dreambot.api.methods.interactive.Players; import org.dreambot.api.script.AbstractScript; import org.dreambot.api.script.Category; import org.dreambot.api.script.ScriptManifest; import org.dreambot.api.script.listener.AnimationListener; import org.dreambot.api.wrappers.interactive.GameObject; import org.dreambot.api.wrappers.interactive.Player; @ScriptManifest(author = "Deep Slayer", name = "Testing script", version = 1.0, description = "for testing snippets", category = Category.MISC ) public class TestingPurposes extends AbstractScript implements AnimationListener { private long idleAnimationStartTime = -1; // Time when the idle animation starts private boolean finishedSmelting = false; @Override public void onPlayerAnimation(Player player, int animation, int animationDelay) { // Check if not animating if (Players.getLocal().getAnimation() == -1) { // If not animating record the time if (idleAnimationStartTime == -1) { idleAnimationStartTime = System.currentTimeMillis(); } else { // Check if it has been more than 2 seconds if (System.currentTimeMillis() - idleAnimationStartTime > 2000) { finishedSmelting = true; log("We are finished smelting"); } } } else { // Reset the timer if the player starts a new animation idleAnimationStartTime = -1; finishedSmelting = false; log("We are NOT finished smelting"); } } @Override public int onLoop() { GameObject furnace = GameObjects.closest("Furnace"); if (furnace != null && furnace.isOnScreen() && Players.getLocal().isStandingStill()) { if (finishedSmelting) { furnace.interact("Smelt"); sleep(2000, 2500); // Adjust sleep as necessary finishedSmelting = false; // Reset flag after interaction } } return 500; } }