Jump to content

What do i do wrong?


Sebastian

Recommended Posts

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
Link to comment
Share on other sites

 

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();
        }
    }
}

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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