Jump to content

Script help


Recommended Posts

Posted

This is my first real script after doing a few basic ones. I am trying to make a script that collects and deposits planks from the barb outpost. It is currently trying to collect planks even when the inventory is full. It also seems to not want to open the bank. If you have solutions to these issues or notice any others please let me know! Thanks you.

 

My code:

 

 

package planks;

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.api.model.GroundItem;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;

import java.awt.*;


@ScriptManifest(name = "Planks", author = "regnivon", version = 1.0, info = "", logo = "")
public class Main extends Script {

    Area PlankArea = new Area(2549, 3579, 2556, 3574);
    Area BankArea = new Area(2531, 3576, 2536, 3570);
    private long startTime = System.currentTimeMillis();
    @@Override
    public void onStart() {
       log("hi");
    }
    
    @@Override
    public void onExit() {
        log("bye");
    }

    
    @@Override
    public int onLoop() {
        Entity player = myPlayer();
        GroundItem plank = groundItems.closest("Plank");
        if (inventory.isFull() && !BankArea.contains(player)) {
            getWalking().webWalk(BankArea);
        }
        if (inventory.isFull() && BankArea.contains(player)) {
            if (getBank().isOpen()) {
                getBank().depositAll();
                  new ConditionalSleep(3000,5000) {
                      @@Override
                      public boolean condition() throws InterruptedException {
                          return (!inventory.isFull());
                      }
                  }.sleep();  
            } else {
                Entity box = objects.closest("Bank chest");
                    if (box != null) {
                        box.interact("Use");
                    }
        }
            
        }if (inventory.isEmpty() && !PlankArea.contains(player)) {
            getWalking().webWalk(PlankArea);
        }
        if (plank != null && !inventory.isFull()) {    
            plank.interact("Take");
            return 500;
        }
        return 500;
    }


    @@Override
    public void onPaint(Graphics2D g2d) {
        super.onPaint(g2d);
        g2d.drawString("Elapsed seconds: " + (int) ((System.currentTimeMillis() - startTime) / 1000), 20, 265);
    }


}

 

Posted

This is my first real script after doing a few basic ones. I am trying to make a script that collects and deposits planks from the barb outpost. It is currently trying to collect planks even when the inventory is full. It also seems to not want to open the bank. If you have solutions to these issues or notice any others please let me know! Thanks you.

My code:

Well isn't it a deposit box not a bank at the barbarian outpost?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...