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.

Need help with script

Featured Replies

I need help with a script I'm trying to make. I'm having trouble collecting things from trees. The script collects for example apples from trees but after it has collected whole tree it just does nothing and doesnt continue collectig from other trees. Can anyone help me? :feels:

 

EDIT: HOLY SHIT I'M BLIND AND STUPID! TREE ID CHANGES :???:

Edited by Abysm

  • Author

Basically just clicking trees until its empty. The action changes from pick -> search if that helps. I've been experimenting with filter but I'm having hart time getting it to work. I'm on phone right now

Edited by Abysm

Check your conditions, make sure you have if inventory isnt full & in apple area pick apples, else if it is full inv in apple area walk to bank, if its in the bank then bank.

  • Author

so I should search tree in area instead of getobject.closest?

Use a filter which checks hasAction("Pick") with closest()

As Zapako said, or check if the ID of the trees changes if it doesn't have any more to pick from.

  • Author

I tried using filter but didnt really know how to use it :D literally making my "first script". and no, tree id stays same

Edited by Abysm

  • Author
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 = "BananaPicker", author = "Abysm", info = "Picks bananas in karamja", version = 0.1, logo = "")
public final class BananaPicker extends Script {

    private final Area BananaArea = new Area(2914, 3161, 2926, 3154);
    private final Area DepositArea = new Area(3045, 3235, 3050, 3237);

    @Override

    public final int onLoop() throws InterruptedException {
        if (canPickBananas()) {
            Pick();
        } else {
            deposit();
        }
        return random(150, 200);
    }

    private void Pick() {
        RS2Object Bananatree1 = getObjects().closest("Banana tree");
        if (!BananaArea.contains(myPosition())) {
            getWalking().webWalk(BananaArea);
        } else if (!getInventory().isFull()) {
            Bananatree1.interact("Pick");
        }
    }

    private boolean canPickBananas() {
        return !getInventory().isFull();
    }

    private void deposit() throws InterruptedException {
        if (!DepositArea.contains(myPosition())) {
            getWalking().webWalk(DepositArea);
        } else if (!getDepositBox().isOpen()) {
            getDepositBox().open();
        } else if (!getInventory().isEmptyExcept("Coins")) {
            getDepositBox().depositAllExcept("Coins");
        } else {
            stop(true);
        }
    }
}

 

So here is basically the whole code, it goes to the deposit box in port sarim if inventory is full and deposits all the bananas, walks back to banana trees, picks one tree out of bananas then it just freezes. Could somebody help a noob? 

Edited by Abysm

Because even when the banana tree runs out of bananas it's still called "Banana tree" in game, you need to check if the closest banana tree still has bananas to pick

  • Author
3 minutes ago, d0zza said:

Because even when the banana tree runs out of bananas it's still called "Banana tree" in game, you need to check if the closest banana tree still has bananas to pick

Thats the problem, I dont know how :D I've been trying to use all sorts of filters but I cant get it to work

Edited by Abysm

3 hours ago, Abysm said:

Thats the problem, I dont know how :D I've been trying to use all sorts of filters but I cant get it to work

Bro, use IDs. The ID changes when it has bananas and when it doesn't.

The ID for the tree with bananas is 2073.

The ID for the tree without bananas is 2078.

So

int fullTree = 2073;
int emptyTree = 2078;

if (fullTree) {
  if (fullTree.interact("Pick")) {
    conditionalSleep -> emptyTree, 5000);
  }
}

You might want to play around with the conditional sleep to fit you.

Edited by Visty

So to edit your code, it should be something like this

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 = "BananaPicker", author = "Abysm", info = "Picks bananas in karamja", version = 0.1, logo = "")
public final class BananaPicker extends Script {

    private final Area BananaArea = new Area(2914, 3161, 2926, 3154);
    private final Area DepositArea = new Area(3045, 3235, 3050, 3237);

    @Override

    public final int onLoop() throws InterruptedException {
        if (canPickBananas()) {
            Pick();
        } else {
            deposit();
        }
        return random(150, 200);
    }

    private void Pick() {
        RS2Object fullTree = getObjects().closest(2073);

        if (!BananaArea.contains(myPosition())) {
            getWalking().webWalk(BananaArea);
        } else if (!getInventory().isFull()) {
            if (fullTree.interact("Pick") {
				//Conditionalsleep
        }
    }

    private boolean canPickBananas() {
        return !getInventory().isFull();
    }

    private void deposit() throws InterruptedException {
        if (!DepositArea.contains(myPosition())) {
            getWalking().webWalk(DepositArea);
        } else if (!getDepositBox().isOpen()) {
            getDepositBox().open();
        } else if (!getInventory().isEmptyExcept("Coins")) {
            getDepositBox().depositAllExcept("Coins");
        } else {
            stop(true);
        }
    }
}

 

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.