Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Where did I go wrong?

Featured Replies

So... This script will work.. kind of. If I start at the yew tree in East Varrock, it'll cut the yew, but after the yew is cut down, it'll run to the next closest yew on the other side of the castle. If I start it anywhere other then that yew tree, it won't walk to it. Can anyone tell me what's wrong with this.. 

 

Spoiler

				
			import org.osbot.rs07.api.map.Area;
		import org.osbot.rs07.api.model.RS2Object;
		import org.osbot.rs07.script.Script;
		import org.osbot.rs07.script.ScriptManifest;				
			@ScriptManifest(name = "MyYewCutter", author = "MySQLi", version = 1.0, info = "Cuts yews in East Varrock", logo = "")				
			public class Main extends Script {				
		    private State state;
		    Area WC = new Area(3247,3472,0,0);
		    Area Bank = new Area(3253,3420,0,0);
		    
		    private enum State{
		        CUT, WALKTOBANK, BANK, WALKTOTREE
		    }
		    
		    private State getState(){
		        if(getInventory().isFull() && Bank.contains(myPlayer())){
		            return State.BANK;
		        }
		        if(getInventory().isFull() && !Bank.contains(myPlayer())){
		            return State.WALKTOBANK;
		        }
		        if(!getInventory().isFull() && WC.contains(myPlayer())){
		            return State.CUT;
		        }
		        if(!getInventory().isFull() && !WC.contains(myPlayer())){
		            return State.WALKTOTREE;
		        }
		        return State.BANK;
		    }
		    
		    public void onStart(){
		        
		    }
		    
		    public int onLoop() throws InterruptedException{
		        state = getState();
		        switch (state){
		        
		        case BANK:
		            if(!getBank().isOpen()){
		                getBank().open();
		            }else{
		                getBank().depositAll();
		            }
		        case WALKTOBANK:
		            getWalking().webWalk(Bank);
		            break;
		            
		        case CUT:
		            if (myPlayer().isAnimating()){
		            }else{
		                if(!myPlayer().isAnimating()){
		                }
		                RS2Object yew = getObjects().closest("Yew");
		                if (yew != null){
		                    yew.interact("Chop down");
		                }
		            }
		            break;
		            
		        case WALKTOTREE:
		            getWalking().webWalk(WC);
		            
		            break;
		            
		        }
		        return random(150,175);
		    }
		}

 

33 minutes ago, MySQLi said:

I do not, it's equipped on my character. 

You are just calling myPlayer.

I think you need to do myPlayer.getPosition()

Like this v

if(!getInventory().isFull() && WC.contains(myPlayer.getPosition())){
	return State.CUT;
}

Reason is, you want to check the yew area against your players current position.

Edited by Visty

  • Author
2 minutes ago, Visty said:

You are just calling myPlayer.

I think you need to do myPlayer.getPosition()


if(!getInventory().isFull() && WC.contains(myPlayer.getPosition())){
		            return State.CUT;
		        }

But WC has a stored x,y position, so wouldn't the client realize my current x,y and the x,y it should be at and move it there?

 

Also, to make your player only cut the yew trees within the area you have selected, you have to do this v

RS2Object yew = getObjects().closest(WC, "Yew");

As you can see, you are telling the bot to check the closest tree in the WC area, against the tree "Yew"

Edited by Visty

  • Author
2 minutes ago, Visty said:

Also, to make your player only cut the yew trees within the area you have selected, you have to do this v


RS2Object yew = getObjects().closest(WC, "Yew");

As you can see, you are telling the bot to check the closest tree in the WC area, against the tree "Yew"

Thank you, that fixes that, but with your other suggestion, it still won't walk to the Woodcutting location... I don't understand why it's not working. 

2 minutes ago, MySQLi said:

But WC has a stored x,y position, so wouldn't the client realize my current x,y and the x,y it should be at and move it there?

Yes, in your WalkToTree method, say something like v

if (!WC.contains(myPlayer.getPosition()) {
  getWalking.walk(yew);
}

In this, you are saying if the player isn't in the WC area, let's walk to it.

  • Author
3 minutes ago, Visty said:

Yes, in your WalkToTree method, say something like v


if (!WC.contains(myPlayer.getPosition()) {
  getWalking.walk(yew);
}

In this, you are saying if the player isn't in the WC area, let's walk to it.

 

3 minutes ago, Visty said:

Yes, in your WalkToTree method, say something like v


if (!WC.contains(myPlayer.getPosition()) {
  getWalking.walk(yew);
}

In this, you are saying if the player isn't in the WC area, let's walk to it.

I tried this, it still won't walk to the yew tree. I don't understand why. 

Just now, MySQLi said:

 

I tried this, it still won't walk to the yew tree. I don't understand why. 

Show me the code you have written

 

  • Author
4 minutes ago, Visty said:

Show me the code you have written

 

	import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
	@ScriptManifest(name = "MyYewCutter", author = "MySQLi", version = 1.0, info = "Cuts yews in East Varrock", logo = "")
	public class Main extends Script {
    private State state;
    Area WC = new Area(3247,3472,0,0);
    Area Bank = new Area(3253,3420,0,0);
    
    private enum State{
        CUT, WALKTOBANK, BANK, WALKTOTREE
    }
    
    private State getState(){
        if(getInventory().isFull() && Bank.contains(myPlayer())){
            return State.BANK;
        }
        if(getInventory().isFull() && !Bank.contains(myPlayer())){
            return State.WALKTOBANK;
        }
        if(!getInventory().isFull() && WC.contains(myPlayer().getPosition())){
            return State.CUT;
        }
        if(!getInventory().isFull() && !WC.contains(myPlayer().getPosition())){
            return State.WALKTOTREE;
        }
        return State.BANK;
    }
    
    public void onStart(){
        
    }
    
    public int onLoop() throws InterruptedException{
        state = getState();
        switch (state){
        
        case BANK:
            if(!getBank().isOpen()){
                getBank().open();
            }else{
                getBank().depositAll();
            }
        case WALKTOBANK:
            getWalking().webWalk(Bank);
            break;
            
        case CUT:
            if (myPlayer().isAnimating()){
            }else{
                if(!myPlayer().isAnimating()){
                }
                RS2Object yew = getObjects().closest(WC, "Yew");
                if (yew != null){
                    yew.interact("Chop down");
                }
            }
            break;
            
        case WALKTOTREE:
            getWalking().webWalk(WC);
            
            break;
            
        }
        return random(150,175);
    }
}

3 minutes ago, MySQLi said:

 

Are you sure that your inventory is not full before walking to the tree? Also, are you sure that the area you have selected for the yew trees isn't including the bank as well?

Edited by Visty

  • Author
4 minutes ago, Visty said:

Are you sure that your inventory is not full before walking to the tree? Also, are you sure that the area you have selected for the yew trees isn't including the bank as well?

Yes, inventory is empty, and I checked the coordinates too. 

10 minutes ago, MySQLi said:

Yes, inventory is empty, and I checked the coordinates too. 

I'm thinking it's because of your states. They all have the same if statements. I can't really identify the problem without logging each statement, and see where the issue is. If you want, I can help you via teamviewer.

Edited by Visty

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.