Jump to content

What do i do wrong?


Recommended Posts

Posted (edited)

Trinity fixed the issue.  God bless haha.

 

But the problem now is. I'm cutting yew logs at varrock castle. There are 3 tree's. 2 standing next to each other, and one is a bit away. We tried to let the character walk to another yew tree, if the tree's i'm standing at are null. 

 

This is the code we have so far. But everything we tried didn't work.

case CHOP:
			Entity treeToChop = getObjects().closest(tree);
			if (treeToChop != null){
				if (treeToChop.getPosition().distance(myPosition()) <= 5){ //checks distance to your player
					if (treeToChop.isVisible()){
						if (treeToChop.interact("Chop down")){
							new ConditionalSleep(2500) {
								@Override
								public boolean condition() throws InterruptedException {
									return myPlayer().isAnimating();
								}
							}.sleep();
						}
					} else {
						getCamera().toEntity(treeToChop);
					}
				} else {
					log("Walking");
					getLocalWalker().walk(treeToChop);
					 //walks if farther than 6 tiles
				}
			} else {
				log("Tree is null"); 
			}
Edited by OSRS Sebastian
Posted

 

Trinity fixed the issue.  God bless haha.

 

But the problem now is. I'm cutting yew logs at varrock castle. There are 3 tree's. 2 standing next to each other, and one is a bit away. We tried to let the character walk to another yew tree, if the tree's i'm standing at are null. 

 

This is the code we have so far. But everything we tried didn't work.

case CHOP:
			Entity treeToChop = getObjects().closest(tree);
			if (treeToChop != null){
				if (treeToChop.getPosition().distance(myPosition()) <= 5){ //checks distance to your player
					if (treeToChop.isVisible()){
						if (treeToChop.interact("Chop down")){
							new ConditionalSleep(2500) {
								@Override
								public boolean condition() throws InterruptedException {
									return myPlayer().isAnimating();
								}
							}.sleep();
						}
					} else {
						getCamera().toEntity(treeToChop);
					}
				} else {
					log("Walking");
					getLocalWalker().walk(treeToChop);
					 //walks if farther than 6 tiles
				}
			} else {
				log("Tree is null"); 
			}

 

 

I could not tell you what is wrong with your code without seeing the full source / testing it for myself. However this script I have just written, works perfectly well on all three Varrock Yews behind the castle, it automatically walks to the third tree if it is not in click-able distance, so perhaps you are over complicating it:


import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;

@ScriptManifest(author = "Explv", name = "Wood Chop Chop", version = 1.0, info = "Chops wood", logo = "")
public class WoodChopChop extends Script {

    @Override
    public int onLoop() throws InterruptedException {

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

            if(getInventory().isFull()) getInventory().dropAllExcept(item -> item.getName().contains("axe"));
            else chop();
        }
        return 0;
    }

    private void chop() {

        RS2Object yew = getObjects().closest("Yew");

        if (yew != null) {

            if (!yew.isVisible()) getCamera().toEntity(yew);

            yew.interact("Chop down");
            new ConditionalSleep(5000) {
                @Override
                public boolean condition() throws InterruptedException {

                    return myPlayer().isAnimating();
                }
            }.sleep();
        }
    }
}

 

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...