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.

Tree cutting help!

Featured Replies

Hi, 

 

I'm still new to scripting and learning java while scripting..

 

but here is the code, I was wondering how would I tell the bot to only cut trees that are in the tree area? Even if it is visible, I don't want the bot to click trees that are not in the area?

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import java.awt.*;

/**
 * Created by Phaibooty on 1/11/2017.
 */

@ScriptManifest(author = "Phaibooty", info = "Chops Logs Only", name ="LogWoodcutter", version = 1, logo ="")
public class SimpleWoodcutter extends Script {

    final String tree_name = "Tree";
    final Area BANK_AREA = new Area(3092,3040,3097,3246);
    final Area Tree_Area = new Area(3103,3226,3114,3233);
    final int BANK_BOOTH_ID = 23961;

    @[member=Override]
    //Code used at Start
    public void onStart() {
        log("lets get started!");
        log("This is where the code begins.");

    }

    @[member=Override]
        public int onLoop() throws InterruptedException {

        if(!inventory.isFull()){
            //Chop
        	
        	if(Tree_Area.contains(myPlayer())){
            Entity tree = objects.closest(tree_name);
            if (tree != null) {
                if (tree.isVisible()) {
                	if(!myPlayer().isAnimating()){
                		if(!myPlayer().isMoving()){
                    tree.interact("Chop down");
                    sleep(random(700,800));
                	}
                } 
            } else {
                    camera.toEntity(tree);
                }
            }
        } else {
        	getWalking().webWalk(Tree_Area);
        }
        }else {
            //bank
        	if (BANK_AREA.contains(myPlayer())){
        		Entity bankbooth = objects.closest(BANK_BOOTH_ID);
        		
        		if(bank.isOpen()){
        			bank.depositAll();
        			
        		}
        		if (bankbooth != null){
        			if(bankbooth.isVisible()){
        				bankbooth.interact("Bank");
        				sleep(random(700,800));
        			}
        			
        		}
       		
        	} else {
        		getWalking().webWalk(BANK_AREA);
        	}
        }

        return random(200, 300);
    }

    @[member=Override]
    //Code used at End
    public void onExit(){
        log("Thanks for using my woodcutter!");
    }

    @[member=Override]
    public void onPaint(Graphics2D g) {

    }

}

Code is really messy and I'm still confused... but hopefully some guidance will help.

Isn't there an area#contains(Entity entity)?

 

If (Tree_area.contains(tree)) {

}

 

or smth

Isn't there an area#contains(Entity entity)?

 

If (Tree_area.contains(tree)) {

}

 

or smth

 

yes there is a methods for it, but then it will do nothing if the entity is not in the area. you want to filter out the ones like i have above :)

  • Author

Isn't there an area#contains(Entity entity)?

 

If (Tree_area.contains(tree)) {

}

 

or smth

 

Thank you!

 

Gave this a try, and works beautifully.

 

Still a little confused on where I should put it, but I guess that just comes with more java knowledge lol.

 

I put it right before tree.isVisible..

 

  @[member=Override]
        public int onLoop() throws InterruptedException {


        if(!inventory.isFull()){
            //Chop
         
         if(Tree_Area.contains(myPlayer())){
            Entity tree = objects.closest(tree_name);
            if (tree != null) {
             if (Tree_Area.contains(tree))
                if (tree.isVisible()) {
                 if(!myPlayer().isAnimating()){
                 if(!myPlayer().isMoving()){
                    tree.interact("Chop down");
                    sleep(random(700,800));
                 }
                } 
            } else {
                    camera.toEntity(tree);
                }
            }

RS2Object tree = getObjects().closest(AREA_HERE, TREE_NAME HERE);

 

check out the api here for more options:

 

http://osbot.org/api/org/osbot/rs07/api/EntityAPI.html

 

shit, explains why it stops chopping after 1 tree. lmao

 

Still a little confused on how to use that line of code but I'll keep reading. Thank you!

Thank you!

 

Gave this a try, and works beautifully.

 

Still a little confused on where I should put it, but I guess that just comes with more java knowledge lol.

 

I put it right before tree.isVisible..

 

  @[member='Override']
        public int onLoop() throws InterruptedException {


        if(!inventory.isFull()){
            //Chop
         
         if(Tree_Area.contains(myPlayer())){
            Entity tree = objects.closest(tree_name);
            if (tree != null) {
             if (Tree_Area.contains(tree))
                if (tree.isVisible()) {
                 if(!myPlayer().isAnimating()){
                 if(!myPlayer().isMoving()){
                    tree.interact("Chop down");
                    sleep(random(700,800));
                 }
                } 
            } else {
                    camera.toEntity(tree);
                }
            }

 

shit, explains why it stops chopping after 1 tree. lmao

 

Still a little confused on how to use that line of code but I'll keep reading. Thank you!

 

here is what it could look like:

 

if(!getInventory().isFull()) {
		            //Chop
			        if(!myPlayer().isAnimating() && !myPlayer().isMoving()) {
			        	 if(TREE_AREA.contains(myPlayer())) {
			        		 Entity tree = getObjects().closest(AREA_HERE, TREE_NAME);
			        		 if (tree != null) {
			        			 if(tree.interact("CHOP??"))
			        				 add sleep here
			        		 }
			        	 }
			        }
		        }

Edited by Precise

  • Author

 

here is what it could look like:

 

if(!getInventory().isFull()) {
		            //Chop
			        if(!myPlayer().isAnimating() && !myPlayer().isMoving()) {
			        	 if(TREE_AREA.contains(myPlayer())) {
			        		 Entity tree = getObjects().closest(AREA_HERE, TREE_NAME);
			        		 if (tree != null) {
			        			 if(tree.interact("CHOP??"))
			        				 add sleep here
			        		 }
			        	 }
			        }
		        }

 

 

Thank you! I appreciate the help. It works beautifully now.

 

Going to do more studying lmao. thanks again

Thank you! I appreciate the help. It works beautifully now.

 

Going to do more studying lmao. thanks again

 

If you're curious to learn more about Java specifically to grow your knowledge, I would recommend these two sources. They're fantastic sources!

 

Source one: 

 

Source two: http://mooc.fi/english.html

if (BANK_AREA.contains(myPlayer())){
        		Entity bankbooth = objects.closest(BANK_BOOTH_ID);
        		
        		if(bank.isOpen()){
        			bank.depositAll();
        			
        		}
        		if (bankbooth != null){
        			if(bankbooth.isVisible()){
        				bankbooth.interact("Bank");
        				sleep(random(700,800));
        			}
        			
        		}

Now there is no need for

Entity bankbooth = objects.closest(BANK_BOOTH_ID);

Instead you can simply use the Bank(Api) to open by using:

getBank().open();

And the second thing is that the logic is wrong instead you can do:

if (BANK_AREA.contains(myPlayer())){
        		
        		if(bank.isOpen()){ // If bank is opened deposit all
        			bank.depositAll();
        			
        		} else { // If bank is not opened open it
        			getBank().open();
                                new ConditionalSleep(5000) { // Conditional Sleep 5000ms untill bank is open.
					@[member=Override]
					public boolean condition() throws InterruptedException {
						return getBank().isOpen();
						}
					}.sleep();
        		}
  • Author
if (BANK_AREA.contains(myPlayer())){
        		Entity bankbooth = objects.closest(BANK_BOOTH_ID);
        		
        		if(bank.isOpen()){
        			bank.depositAll();
        			
        		}
        		if (bankbooth != null){
        			if(bankbooth.isVisible()){
        				bankbooth.interact("Bank");
        				sleep(random(700,800));
        			}
        			
        		}

Now there is no need for

Entity bankbooth = objects.closest(BANK_BOOTH_ID);

Instead you can simply use the Bank(Api) to open by using:

getBank().open();

And the second thing is that the logic is wrong instead you can do:

if (BANK_AREA.contains(myPlayer())){
        		
        		if(bank.isOpen()){ // If bank is opened deposit all
        			bank.depositAll();
        			
        		} else { // If bank is not opened open it
        			getBank().open();
                                new ConditionalSleep(5000) { // Conditional Sleep 5000ms untill bank is open.
					@[member='Override']
					public boolean condition() throws InterruptedException {
						return getBank().isOpen();
						}
					}.sleep();
        		}

 

Wow. Beautiful. Thank you for the help. 

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.