crafting problem

Hi,
I’m trying to add a simple craft system. You click a button, it checks if you have all the requirements and then it just adds it to the inventory. My problem is currently it will create the item if the player has met any requirement for any item but I want to check if they meet the requirements for every item in the Crafting Map.

This is the item I am trying to craft, you can see the map values here

This is how I query what Items the player has

You’re removing all the usable items from the inventory without checking if they are all useable.

You need to loop round once, just to check everything is ok, then remove them from the inventory.

I tried a while loop earlier but kept getting infinite loops

You just need to do the whole loop once to check everything’s ok, then again to do the crafting :slight_smile:

Could you elaborate a bit more, I just started to understand maps and arrays but now I’m at a loss.

Ideally something like this would do the trick (I know the array only returns 1st index)

Like this

Check, then do it.

The code isn’t actually functional, it’s more the concept that matters.

1 Like

Thankyou, works perfectly

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.