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.

trying to create a woodcutting script

Featured Replies

Do you have the required axe in your bank at all? Aftering checking if the bank is open, nest another if statement (or use a logical operator on the same line) that checks whether the axe is in your bank at all. If (bank.contains(Axetouse) && bank.withdraw(Axetouse, 1)) new ConditionalSleep(3000, 25). Return on that sleep whether your inventory contains the axe.

  • Author

Axe was in the bank and i had already added the if statement to look if the axe was
in the bank but thanks anyway Now I´m trying to create the script that if the axe isn´t in the bank he will sell the logs you harvested and buy the axe but I can't figure out how to open the offer slot in the ge (note i'm already in the ge ).

 RS2Widget Openbuymenu = getWidgets().get(465, 7, 26);
                                if(Openbuymenu != null) {
                                    Openbuymenu.interact("Buy");
                                    new ConditionalSleep(5000) {
                                        public boolean condition() throws InterruptedException {
                                            return grandExchange.isOfferScreenOpen();
                                        }
                                    }.sleep();
                                }
                                keyboard.typeString(AxeToUse());
                                int Offerprice = grandExchange.getOfferPrice();
                                grandExchange.setOfferPrice( 2 * Offerprice );

 

  • Author

I watched it, but I wanted to learn how to work with widgets. It would be possible with widgets if I am not mistaken. but I will look again to your link and try it out and if it is possible could you still tell me what was wrong with my code for the future.

9 minutes ago, heervangrijsburg said:

It would be possible with widgets if I am not mistaken.

It would be. I commend you for creating your own methods for the GE.

Are you certain that "Buy" is the right interact string? When hovering I see "Create Buy offer". Alternatively, you can ask for the x, y coordinate of that widget and create a rectangle based on the x, y, width and height. Then you can click on that with the mouse class.

  • Author

hello,

thanks @Steel Poster but I now use "grandExchange.buyItem".

Now I´m getting this error and i don´t know how to fix it :

222336162_Screenshot(325).thumb.png.4d3808f8c8cf7f166c4687494c007c4c.png

this is the part of the code I think the problem is in but like I said I don´t know how to fig it

Main class

Spoiler

package script;

import items.Axe;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import tasks.*;

@ScriptManifest(author = "Heervangrijsburg", logo = "", info ="Cuts trees" , version = 1.2 , name = "Tree chopper")
public final class Main extends Script {
    private final GoChopTree goChopTree = new GoChopTree();
    private final GoBank goBank = new GoBank();
    private final Axe axe = new Axe();
    private final GoGetAxe gogetaxe = new GoGetAxe();



    @SuppressWarnings("deprecation")
    @Override
    public void onStart() {
        goChopTree.exchangeContext(getBot());
        goBank.exchangeContext(getBot());
        axe.exchangeContext(getBot());
        gogetaxe.exchangeContext(getBot());
    }

    @Override
    public void onExit() {

    }

    @Override
    public int onLoop() throws InterruptedException {
        log("start oke");
        if (inventory.isEmptyExcept(1511, 1353,1361,1355,1357,1359,1351)) {
            log ("section 2");
            if (!inventory.isFull()) {
                log ("section 3");
                if (inventory.contains(axe.AxeToUseName())) {
                    log ("section 4");
                    goChopTree.choptree();
                } else {
                    gogetaxe.getsrightaxe();
                }
            } else {
                log ("section 2,1");
                goBank.bankafterchopptingtrees();
            }
        } else {
            log ("section 1,1");
            goBank.bankinventoryjunk();
        }
        return 1000;
    }
}

 

 

GoGetAxe class :

Spoiler

package tasks;

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.script.MethodProvider;
import org.osbot.rs07.utility.ConditionalSleep;
import items.Axe;
import pricege.*;

public final class GoGetAxe extends MethodProvider {
    private Axe axe = new Axe();
    private Area bank_area = new Area(
            new int[][]{
                    { 3092, 3246 },
                    { 3092, 3240 },
                    { 3097, 3240 },
                    { 3097, 3246 }
            }
    );
    private Area grandexchange_Area = new Area(
            new int[][]{
                    {3162, 3486},
                    {3168, 3486},
                    {3168, 3493},
                    {3161, 3492}
            }
    );

    public void getsrightaxe() throws InterruptedException {
        if (bank_area.contains(myPlayer())) {
            if (bank.isOpen()){
                if (bank.contains(axe.AxeToUseName())){
                    bank.withdraw(axe.AxeToUseName(), 1);
                } else {
                    buyrightaxe();
                }
                bank.close();
                new ConditionalSleep(5000){
                    public boolean condition() throws InterruptedException {
                        return !bank.isOpen();
                    }
                }.sleep();
            } else {
                bank.open();
                new ConditionalSleep(5000){
                    public boolean condition() throws InterruptedException {
                        return bank.isOpen();
                    }
                }.sleep();
            }
        } else {
            getWalking().webWalk(bank_area);
            new ConditionalSleep(5000) {
                public boolean condition() throws InterruptedException {
                    return bank_area.contains(myPlayer());
                }
            }.sleep();
        }
    }

 

Axe class

Spoiler

package items;

import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.script.MethodProvider;

public class Axe extends MethodProvider {
    public String AxeToUseName() {
        if (skills.getDynamic(Skill.WOODCUTTING) <= 10) {
            return "Steel axe";
        } else if (skills.getDynamic(Skill.WOODCUTTING) <= 20) {
            return "Black axe";
        } else if (skills.getDynamic(Skill.WOODCUTTING) <= 30) {
            return "Mithril axe";
        } else if (skills.getDynamic(Skill.WOODCUTTING) <= 40) {
            return "Adamant axe";
        } else if (skills.getDynamic(Skill.WOODCUTTING) <= 99) {
            return "Rune axe";
        } else {
            return "bronze axe";
        }
    }
    public int AxeToUseID() {
        if (skills.getDynamic(Skill.WOODCUTTING) <= 10) {
            return 1353;
        } else if (skills.getDynamic(Skill.WOODCUTTING) <= 20) {
            return 1361;
        } else if (skills.getDynamic(Skill.WOODCUTTING) <= 30) {
            return 1355;
        } else if (skills.getDynamic(Skill.WOODCUTTING) <= 40) {
            return 1357;
        } else if (skills.getDynamic(Skill.WOODCUTTING) <= 99) {
            return 1359;
        } else {
            return 1351;
        }
    }
}

 

 

Edited by heervangrijsburg
adding Axe class

Possibly because you are calling the Axe class from GoGetAxe class and have not exchangedContext between these two classes. Can't say for sure. Let me know if that works, or if it does not.

Edited by Athylus

  • Author

Thanks it worked I´m getting an other error now but I haven´t had time to look into it myself if I can't figure it out I will let you know. Thanks for the help so far.

If I were you, I'd take a look into what classes/methods are just in general in Java.

It seems like you have classes for simple tasks where methods would be sufficient. Having a class for just a small task is not advised and very bad coding habits.

Look into object-oriented programming as that's what Java was developed for :)

Edited by Rays

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.