Jump to content
cjeee

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

Recommended Posts

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

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

Link to comment
Share on other sites

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

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

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