Need help with nested for loop searching

Hello, i am doing a project at the moment for uni and the requirement is to use blueprints. Which is annoying as we are programmers being made to do this using blueprints. Basically what I want to do is pass in a list of required “Keys” as an array of strings and compare them to the players inventory which is also an array of strings. I can show you how i would do it in C++ which would take me 2 minutes literally…

string] requiredKeys; //passed
string] inventory; //local
int requiredKeysAmmount; //local
bool] hasKeys //local

//Required keys is passed in and inventory is a variable that is held in the function
//within the interface.

//Loop for the ammount of keys we are looking for
for(int x = 0; x < RequiredKeys.size(); x++)
	//Then loop for the inventory
	for(int y = 0); y < inventory.size(); y++)
		if(inventory[y] == requiredKeys[x])
			//We have one of the keys we are looking for...
			hasKeys[x] = true;

if(hasKeys.size() == requiredKeysAmmount)
	return true
	return false;

But blueprints are a mess to do simple things like this from my experience with kismet. Since this is the criteria of our assessment I have to make this in a blueprint. here is what i have currently as my blueprint:

Can anyone please help me with implementing this stupidly easy piece of code into the nightmare that is blueprints? (Well to me atleast!)

Seems like youre checking if inventory contains an item thats inside it in the second loop. Double check that the “contains” node is hooked up properly :slight_smile:

Should the output of that node be set into something?

Blueprints are different than Kismet. There’s absolutely no reason you can’t do this in Blueprints. The link for your Blueprint is not displaying for me. Use the branch node instead of the C++ if, and use the Get function instead of ] off the array and it’s the same otherwise.

The problem i am having now is that the door is opening even when it has incorrect keys. For instance if i pick up Key1 Key2 and Key4 and the door needs Key1 Key2 and Key3 it still opens?

Right click on the icon and select open in other tab. Its just the embeder taking a fit.

I got it working guys, i needed a branch statement after the second loop body, deciding whether or not the current item was a needed key. Thanks for the help.