Jump to content

Cooking bot, double click


Recommended Posts

Posted (edited)

try sleep untill my player is animating. (for the fire interact part)

 

What you have, sleep untill inv does not contain raw,// always returns true

edit: the way you have it set up, it returns true always, that's why its spamming

 

I think that'll work, if not, rip

Edited by dreameo
  • Like 1
Posted
16 minutes ago, kingbutton said:

Okay so I got it to chill after it does "Cook all", and technically my code is working smoothly, but there's one thing that is unhuman like and needs to be address.

 When it tries to interact with the fire, it tries to click several times, kind of like the thing issue I had before. It doesn't bug out or anything, but it bothers me that does it, any solutions?

I tried working with the sleep, but it's not working.


public class Main extends Script {

	long lastAnimation = 0;

	@Override
	public int onLoop() throws InterruptedException {

		if (invCheck()) {
			if (fireCheck()) {

				log("Go cook");

				if (myPlayer().isAnimating()) {
					lastAnimation = System.currentTimeMillis();
				} else if (System.currentTimeMillis() > (lastAnimation + 12000)) {
					goCook();
				}
			} else {
				log("Make fire");
				makeFire();
			}
		} else {

		}

		return 50;
	}

public void goCook() {

		RS2Object fire = objects.closest("Fire");
		RS2Widget optionMenu = getWidgets().get(307, 2);

		if (inventory.interactWithNameThatContains("Use", "Raw")) {
			

			if (optionMenu != null) {
				if (optionMenu.interact("Cook All")) {
					new ConditionalSleep(random(3000, 4500)) {

						@Override
						public boolean condition() throws InterruptedException {
							return myPlayer().isAnimating();
						}
					}.sleep();

				}
			} else {

				if (!myPlayer().isAnimating() && !myPlayer().isMoving()) {

					if (fire.interact("Use")) {
						//Sleep.sleepUntil(() -> !getInventory().contains("raw"), 12000);
                        			new ConditionalSleep(random(3000, 4500)) {
						@Override
							public boolean condition() throws InterruptedException {
								return myPlayer().isAnimating();
							}
						}.sleep();
					}
				}

			}
		}

	}

 

The sleep you were using after interacting with the fire (the one I commented out in the quote) was returning true right away since your inventory will never contain anything with the exact name "raw". The conditional sleep I replaced it with should work.

  • Like 1

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...