Jump to content

Need some help!


MySQLi

Recommended Posts

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
Link to comment
Share on other sites

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