BahNahNah Posted April 24, 2016 Share Posted April 24, 2016 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)); } } } } Quote Link to comment Share on other sites More sharing options...
iJodix Posted April 24, 2016 Share Posted April 24, 2016 (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 April 24, 2016 by iJodix 1 Quote Link to comment Share on other sites More sharing options...
BahNahNah Posted April 24, 2016 Author Share Posted April 24, 2016 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"); Quote Link to comment Share on other sites More sharing options...
iJodix Posted April 24, 2016 Share Posted April 24, 2016 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"); 1 Quote Link to comment Share on other sites More sharing options...
BahNahNah Posted April 24, 2016 Author Share Posted April 24, 2016 I got it working now, it was something to do with my Tree Area. Thanks for your help. 1 Quote Link to comment Share on other sites More sharing options...
Vilius Posted April 24, 2016 Share Posted April 24, 2016 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 Quote Link to comment Share on other sites More sharing options...
TFW Posted April 24, 2016 Share Posted April 24, 2016 http://osbot.org/forum/topic/96505-osbot-scripting-basics-and-snippets/ Quote Link to comment Share on other sites More sharing options...