Jump to content

Need help checking an array with inventory.containsAll()


Recommended Posts

Posted (edited)

Working on a slayer script, each task sets an array of any needed items for that specific task. 
I'm trying to check that

if(inventory.containsAll("Enchanted gem", myTeleItem, myFood, Arrays.toString(myNeededItemsNames)) && 
   inventory.onlyContains("Enchanted gem", myTeleItem, myFood, Arrays.toString(myNeededItemsNames))){
  //do stuff
}

I get that this isn't working because the Arrays.toString is putting out a single string and its looking for an item named "this, this, and that", but is there a simple way to go about what I'm trying to do here?

 

Edit:

as of now I'm just adding the other items to all tasks needed items array, but if someone knows how to go about what I was trying to do, I'd appreciate the information.

Edited by Alakazizam
Posted
4 hours ago, Alakazizam said:

Working on a slayer script, each task sets an array of any needed items for that specific task. 
I'm trying to check that

if(inventory.containsAll("Enchanted gem", myTeleItem, myFood, Arrays.toString(myNeededItemsNames)) && 
   inventory.onlyContains("Enchanted gem", myTeleItem, myFood, Arrays.toString(myNeededItemsNames))){
  //do stuff
}

I get that this isn't working because the Arrays.toString is putting out a single string and its looking for an item named "this, this, and that", but is there a simple way to go about what I'm trying to do here?

 

Edit:

as of now I'm just adding the other items to all tasks needed items array, but if someone knows how to go about what I was trying to do, I'd appreciate the information.

Just like you said, built up 1 list with all items required and check that :)

  • Like 1

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