MySQLi Posted June 24, 2017 Share Posted June 24, 2017 (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 June 24, 2017 by MySQLi Quote Link to comment Share on other sites More sharing options...
Void Posted June 24, 2017 Share Posted June 24, 2017 (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 June 24, 2017 by Void Quote Link to comment Share on other sites More sharing options...
Eliot Posted June 24, 2017 Share Posted June 24, 2017 (edited) Check if inventory is full: if (getInventory().isFull()) ... Deposit all except axe: getBank().depositAllExcept((Filter<Item>) item -> item.getName().contains("axe")); Edited June 24, 2017 by Eliot Quote Link to comment Share on other sites More sharing options...
MySQLi Posted June 24, 2017 Author Share Posted June 24, 2017 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! Quote Link to comment Share on other sites More sharing options...
Mumble Posted June 24, 2017 Share Posted June 24, 2017 Just a tip, you probably want some sleeps inbetween each of your actions, ie: getBank().open(); sleep(random(100,500)); getBank().depositAll("Yew Logs"); Quote Link to comment Share on other sites More sharing options...
Eliot Posted June 24, 2017 Share Posted June 24, 2017 You need brackets if(yew != null && yew.interact("Chop down")) { new ConditionalSleep(5000){ public boolean condition(){ return myPlayer().isAnimating() || !yew.exists(); } }.sleep(); } Quote Link to comment Share on other sites More sharing options...