Jump to content

need help with inventory.isFull() & inventory.isEmptyExcept(xx)


Recommended Posts

Posted (edited)

EDIT; Guys, I still need help, please scroll down and help me please :s

so what im trying to do is return a state for banking once the inventory becomes full and the same thing for if its empty even tho its containing 2 different items, here is my code

	private enum State {
		ERROR, WALKBACK, BANK, WAIT,
	};
	
	private State getState() {
		if (!inventory.contains(563) || !equipment.contains(1381))
		{
			log("State ERROR returned");
			return State.ERROR;
		}
		
		}
		if (inventory.isEmptyExcept(563, 555) || inventory.isEmptyExcept(563))
		{
			log("State WALKBACK returned");
			return State.WALKBACK;
		}
		if (inventory.isFull())
		{
			log("State BANK returned");
			return State.BANK;
		}
		return State.WAIT;
	}

idk if im doing this right but shouldnt it log out my text if my inventory is full/isEmptyExcept(xx)? its not working but all of my other getStates are working just fine

 

so im obviously missing something or using the wrong methods

Edited by cjeee
Posted

so what im trying to do is return a state for banking once the inventory becomes full and the same thing for if its empty even tho its containing 2 different items, here is my code

	
isEmptyExcept();

is broken.

A fix along the lines of:

 

 boolean inventoryEmptyExcept(final int...ints){
        return !inventory.contains(new Filter<Item>() {
            @Override
            public boolean match(Item item) {
                return item != null && !Arrays.asList(ints).contains(item.getId());
            }
        });
    }

Could be edited to strings ect

Posted (edited)
isEmptyExcept();

is broken.

A fix along the lines of:

 

 boolean inventoryEmptyExcept(final int...ints){
        return !inventory.contains(new Filter<Item>() {
            @Override
            public boolean match(Item item) {
                return item != null && !Arrays.asList(ints).contains(item.getId());
            }
        });
    }

Could be edited to strings ect

 

Im getting these errors in my code when i put them in:

 

"The method contains(List<Item>) in the type ItemContainer is not applicable for the arguments (new Filter<Item>(){})"

 

Also

 

getting an error under "match(Item item)

public boolean match(Item item)

"The method match(Item) of type new Filter<Item>(){} must override or implement a supertype method"

 

im sorry i am a noob at this but im always willing to learn! biggrin.png

 

EDIT: I added the import and im getting a warning message under all of the code you send me now

"Type safety: A generic array of Filter<Item> is created for a varargs parameter"

 

Edited by cjeee
Posted (edited)
import org.osbot.rs07.api.filter.Filter;
import org.osbot.rs07.api.model.Item;
import java.util.Arrays;

these ones?

 

 

yessir!

 

EDIT: When i added the code:

if (inventoryEmptyExcept(563, 555) || inventoryEmptyExcept(563))
		{
			log("State WALKBACK returned");
			return State.WALKBACK;
		}

along with the warning below, i still don't receive a log back when those conditions are met.

can somebody please help me? sad.png

 

Edited by cjeee

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