Jump to content

Walking to Entity


Recommended Posts

Posted

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


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
Posted
		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");
Posted

 

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");
  • Like 1
Posted

 

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

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