Jump to content

Need some help!


Recommended Posts

Posted (edited)

Hey guys, sorry I post so many help topics, but what better way to learn then to ask questions?! I'm trying to check my inventory, and I've read a few tutorials now, even taking notes, but I can't find an exact answer or tutorial explaining how to do this! Basically, I'm making a simple Varrock Yew Cutter, the first thing I want to do is check to make sure the inventory isn't already full! 

 

How would I go about that 

Psuedo Code I wrote, so you guys can follow what exaclty I'm doing, Only need guidance on how to check the current status of my inventory and if it is full!

 

I have another question, here is my code so far, wondering why my conditional sleep on cut isn't working? 

Spoiler

import org.osbot.rs07.api.Bank;
import org.osbot.rs07.api.Inventory;
import org.osbot.rs07.api.map.Position;
import org.osbot.rs07.api.map.constants.Banks;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.api.util.ItemContainer;
import org.osbot.rs07.script.Script;

import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;

import java.awt.*;

@ScriptManifest(author = "MySQLi", info = "Varrock Yew Cutter / Banker", name = "SqlYewCutter", version = 1.0, logo = "")

public class Main extends Script {

    @Override
    public void onStart() {
        log("Enjoy cutting yews!");
        //Code here will execute before the loop is started
    }

    

    @Override
    public void onExit() {
        log("Thank you for supporting my script!");
        //Code here will execute after the script ends
    }

    private void bank() throws InterruptedException{
        if(inventory.isFull() && !Banks.VARROCK_WEST.contains(myPosition())){
            getWalking().webWalk(Banks.VARROCK_WEST);
        }
        else if (!getBank().isOpen()){
            getBank().open();
            getBank().depositAll("Yew Logs");
        }
        else{
            getWalking().walk(new Position(3247,3472,0));
        }
    }
  
    
    private void cut(){
            RS2Object yew = getObjects().closest("Yew");
            if(yew != null && yew.interact("Chop down"));
            new ConditionalSleep(5000){
                public boolean condition(){
                    return myPlayer().isAnimating() || !yew.exists();
                }
            }.sleep();
    }

    public boolean canCutTrees(){
        return myPlayer().isOnScreen();
        
    }
    
    
    public int onLoop() throws InterruptedException{
        if(canCutTrees()){
            cut();
        }
        else{
            bank();
        }
    
        
        return random (150,200); //The amount of time in milliseconds before the loop starts over
    }

    @Override
    public void onPaint(Graphics2D g) {
        //This is where you will put your code for paint(s)
    }

}
Edited by MySQLi
Posted (edited)
if(inventory.isFull()){
// code here whatever you want it do do if inv is full
}

Or if you want a seperate class for it..

 

	public dropItems(MethodProvider api) {
		super(api);
	}

	@Override
	public boolean canProcess() {
		return api.getInventory().isFull();
	}

	@Override
	public void process(){
		api.log("Dropping items...");
		api.getInventory().dropAll("Items to drop","Items to drop");
		new ConditionalSleep(MethodProvider.random(2000,3000)) {
            public boolean condition() throws InterruptedException {
            	return api.getInventory().isEmpty();
            }
         }.sleep();
	}
}

 

Edited by Void
Posted
50 minutes ago, Eliot said:

Check if inventory is full:


if (getInventory().isFull()) ...

Deposit all except axe:


getBank().depositAllExcept((Filter<Item>) item -> item.getName().contains("axe"));

 

Thanks man, got that working, got one more question if you have a second, posted it up top!

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...