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.

Open Source Woodcutting Script

Featured Replies

Written this up quickly. Banks at Varrock West and chops Trees to 15, Oaks to 60 and Yews 60+. Doesn't check for axes etc, I'll leave that for you to add. :) 

 

 

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.map.constants.Banks;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;

@ScriptManifest(name = "Free Woodcutter", version = 1.0, author = "HeyImJamie", info = "", logo = "")
public class Main extends Script {

    @Override
    public int onLoop() throws InterruptedException {

        if (shouldBank()) {
            bank();
        } else {
            cutTree(getTreeName());
        }
        return 100;
    }

    private boolean shouldBank() {
        return getInventory().isFull();
    }

    private void bank() throws InterruptedException {
        if (!Banks.VARROCK_WEST.contains(myPlayer())) {
            getWalking().webWalk(Banks.VARROCK_WEST);
        } else {
            if (!getBank().isOpen()) {
                getBank().open();
            } else {
                getBank().depositAllExcept(axes -> axes.getName().contains(" axe"));
            }
        }
    }

    private void cutTree(String treeName) {
        if (!getTreeArea().contains(myPlayer())) {
            getWalking().webWalk(getTreeArea());
        } else {
            RS2Object tree = getObjects().closest(treeName);
            if (!myPlayer().isAnimating() && tree != null) {
                if (tree.interact("Chop down")) {
                    new ConditionalSleep(5000) {
                        @Override
                        public boolean condition() throws InterruptedException {
                            return myPlayer().isAnimating();
                        }
                    }.sleep();
                }
            }
        }
    }

    private Area getTreeArea() {
        if (getSkills().getDynamic(Skill.WOODCUTTING) >= 60) {
            return new Area(3203, 3506, 3225, 3497);
        } else {
            return new Area(3171, 3425, 3159, 3399);
        }
    }

    private String getTreeName() {
        if (getSkills().getDynamic(Skill.WOODCUTTING) >= 60){
            return "Yew";
        } else if (getSkills().getDynamic(Skill.WOODCUTTING) >= 15){
            return "Oak";
        } else {
            return "Tree";
        }
    }
}

 

 
 
 

Edited by HeyImJamie

  • Author
2 minutes ago, Seriously said:

Is this the JSlayer :doge:

This is better than JSlayer :boge: 

Remember, people can't learn from something that isn't tested. If something is broken, it will probably just confuse them even more. 

Looks to me Explv has his hands around your neck

Now this is what I'm talking about.

 

Added to the collection.

 

Would like if you tested it first tho

Edited by Antonio Kala

  • Author
2 minutes ago, Tom said:

Looks to me Explv has his hands around your neck

I wanted to grow his lil e-peen, I still fanboy Tasks :boge: 

5 minutes ago, ProjectPact said:

Remember, people can't learn from something that isn't tested. If something is broken, it will probably just confuse them even more. 

Was just strings I didn't check. I'll load OSbot now and confirm :) 

  • Author
1 minute ago, ProjectPact said:

Great contribution though! Was just giving you some advice, not bashing :)

You made a good point! As it happened I'd put in an incorrect string, so someone would've been confused! :P 

7 minutes ago, Antonio Kala said:

Now this is what I'm talking about.

 

Added to the collection.

 

Would like if you tested it first tho

Tested, Works. :boge: 

9 minutes ago, HeyImJamie said:

You made a good point! As it happened I'd put in an incorrect string, so someone would've been confused! :P 

Tested, Works. :boge: 

Awesome work Jamie!! :doge:

@HeyImJamie

Looks nice, good job

Just FYI you should be checking if wc levels are >=, rather than >. Right now your script will keep chopping normal trees until level 16, and oaks until level 61.

Also you might want to consider using an enum for storing your Tree names & areas. Something like this:

enum Tree {
    NORMAL("Tree", 1, new Area(1, 2, 3, 4)),
    OAK("Oak", 15, new Area(1, 2, 3, 4)),
    YEW("Yew", 60, new Area(1, 2, 3, 4));

    String name;
    int levelRequired;
    Area area;

    Tree(final String name, final int levelRequired, final Area area) {
        this.name = name;
        this.levelRequired = levelRequired;
        this.area = area;
    }
}

 

You can also avoid having lots of nested if statements, by just inverting them:

if (getTreeArea().contains(myPlayer())) {
  if ..
    if ..
} else {
  getWalking().webWalk(...);
}

Becomes:

if (!getTreeArea().contains(myPlayer())) {
    getWalking().webWalk(...);
} else if {
    ... 
} ...

 

Edited by Explv

Looks good, pretty similar to progressiveWC. You have a lot of nested if statements that could be shortened (e.g. if (tree != null && tree.interact("Chop down")). Tree names and areas should be final constants declared once instead of returning a new area/string each time. Logic of the script has some quirks such as not switching to the next tree when the current tree is chopped down (by someone else) and waiting until the animation ends.

  • Author
7 minutes ago, Explv said:

@HeyImJamie

Looks nice, good job

Just FYI you should be checking if wc levels are >=, rather than >. Right now your script will keep chopping normal trees until level 16, and oaks until level 61.

Also you might want to consider using an enum for storing your Tree names & areas. Something like this:


enum Tree {
    NORMAL("Tree", 1, new Area(1, 2, 3, 4)),
    OAK("Oak", 15, new Area(1, 2, 3, 4)),
    YEW("Yew", 60, new Area(1, 2, 3, 4));

    String name;
    int levelRequired;
    Area area;

    Tree(final String name, final int levelRequired, final Area area) {
        this.name = name;
        this.levelRequired = levelRequired;
        this.area = area;
    }
}

 

You can also avoid having lots of nested if statements, by just inverting them:


if (getTreeArea().contains(myPlayer())) {
  if ..
    if ..
} else {
  getWalking().webWalk(...);
}

Becomes:


if (!getTreeArea().contains(myPlayer())) {
    getWalking().webWalk(...);
} else if {
    ... 
} ...

 

Never thought about Enums before. Will definitely use in the future :)

I'll update in regards to the >= and nested if's though

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.