Jump to content

When you level Wc Stuck.


Mocro

Recommended Posts

It should ignore the level up widget... Post your code where it gets stuck

After i click the level up away it works fine this code happens then ->
 if(level >= 31 && this.myPosition().getY() > 3402)
       try{
        inventory.dropAll("Oak logs");
        this.localWalker.walkPath(PathWillows);
       }catch(Exception e){
       
       }

and if the level up dialogues is there this happend and there is no willow tree in sight so thats why the error. ->

	  		if (level >= 31){
		    	if ((!this.inventory.isFull()) && (!myPlayer().isAnimating()))
			    {
			      Entity tree = this.objects.closest(11755);
			    
			      for (int i = 0; i < Willow.length; i++) {   
			    if(tree.isVisible() && tree.getY() == Willow[i])
			    	try{	
			    			tree.interact("Chop Down");
			    			status = "Cutting Willow.";
			    	sleep(random(75, 150));
			    	}catch(Exception e){
			    	
			    	}	    
			      }			 
			}  
		    	}

i got it need to call it before cutting in loop :p

Edited by Mocro
Link to comment
Share on other sites

If you fixed it, then great.

 

However, why are you a for loop here?

for (int i = 0; i < Willow.length; i++) {   // why?
			    	    
}	

Also, you don't really need to try and catch when doing an action. Just make sure the object is not null.

cords dont want all tree's just 2 

 

i  always use try and catch i just forgot on that one lol 

 

anyway its fixed now i put it at the first line of the loop 

before cutting the tree :)

Edited by Mocro
Link to comment
Share on other sites

Make a filter to only get the 2 desired willow trees. I would not recommend using a for loop like you did.

 

Btw, do you know what try & catch is for? If not, read it up and you'll then understand why you don't have to use it like you are now.

i know what a try catch is i always use it i just forgot for that one :P

 

can you send me a example with a filter please? never did that before

Link to comment
Share on other sites

i know what a try catch is i always use it i just forgot for that one tongue.png

 

can you send me a example with a filter please? never did that before

Dude, I am suggesting to NOT use try & catch like how you are using it.

 

Try something like this:

RS2Object tree = getObjects().closest(new Filter<RS2Object>() {

			@Override
			public boolean match(RS2Object obj) {
				return obj.getPosition().equals(WILLOW_POSITION_1) || obj.getPosition().equals(WILLOW_POSITION_2);
			}
			
});

then check if tree != null and do action. 

 

Play around with it and learn how to use filters; it will help you A LOT when using filters.

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

Dude, I am suggesting to NOT use try & catch like how you are using it.

 

Try something like this:

RS2Object tree = getObjects().closest(new Filter<RS2Object>() {

			@Override
			public boolean match(RS2Object obj) {
				return obj.getPosition().equals(WILLOW_POSITION_1) || obj.getPosition().equals(WILLOW_POSITION_2);
			}
			
});

then check if tree != null and do action. 

 

Play around with it and learn how to use filters; it will help you A LOT when using filters.

ow lmao soz why not though about the try and catch and thanks for the filter :)

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