Jump to content

Walking to Entity


BahNahNah

Recommended Posts

I am trying to walk to an entity if it is not visible. My scripts cuts the trees but then just stands there and does nothing... This is my code so far:

Entity tree = sI.objects.closest("Tree");

        if (!sI.inventory.isFull() && tree != null) {
            if (tree.isVisible()) {
                if (!sI.myPlayer().isMoving() && !sI.myPlayer().isAnimating()) {
                    tree.interact("Chop down");
                    sleep(random(400, 800));
                } else if (tree != null && !tree.isVisible()){
                    // Walk to tree
                    sleep(random(400, 1000));
                }
            }
        }
    }
Link to comment
Share on other sites


if (tree != null) {

if (tree.isVisible()) {

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

if (tree.interact("Chop down")) {

return 1000;

}

}

} else {

if (myPlayer().getPosition().distance(tree) <= 9) {

getCamera().toEntity(tree);

} else {

getWalking().walk(tree);

}

}

}

Edited by iJodix
  • Like 1
Link to comment
Share on other sites

		if (tree != null) {
			if (tree.isVisible()) {
				if (!myPlayer().isAnimating() && !myPlayer().isMoving()) {
					if (tree.interact("Chop down")) {
						return 1000;
					}
				}
			} else {
				if (myPlayer().getPosition().distance(tree) <= 9) {
					getCamera().toEntity(tree);
				} else {
					getWalking().walk(tree);
				}
			}
		}

 

 

I changed it to this, but when I start the script it still stands there - if I pause the script and move myself it starts chopping but then it just stands still again. Is this correct?

Entity tree = sI.objects.closest("Tree");
Link to comment
Share on other sites

 

I changed it to this, but when I start the script it still stands there - if I pause the script and move myself it starts chopping but then it just stands still again. Is this correct?

Entity tree = sI.objects.closest("Tree");

 

 

 

Just do;

RS2Object tree = getObjects().closest("Tree");

http://osbot.org/forum/topic/93981-guidetypes-of-entities-and-how-to-use-them-correctly/ this might help too, its a guide about entity types :P

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