Jump to content

Script help


regnivon

Recommended Posts

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);
    }


}

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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