Invalid operands 'Object' and 'Array' in operator '=='

Godot Version

godot 4.2


ive been stuck at this error for a few, cant seem to fix the issue, can anyone explain a solution? please and thank you!

You are comparing incompatible datatypes.
slot.item is of type Object (can’t see from your screenshot details about that)
materialsNeeded is an array containing materials[0], materials[1].

Perhaps you would need to compare each element of materialsNeeded with slot.item? Depends on what you want to achieve.

how would i do that?

It is still unclear to me what you want to achieve.

im trying to get it to check if the player has the materials in their inventory, and if it does subtracts the amount of each material.

Should the subtraction happen for each component separately or should it only happen, if the player has enough of all materials?

enough of all materials

this is some harvesting a tree with axe and max harvesting item is 3 woods?

or needed 3 woods for create axe?

or 2 woods and one metal? :smiley:

Then you need two loops. In the first loop, you will need to verify, if all materials are available.
In the second loop you will need to subtract the amounts.
Currently you only have a single loop in which you verify AND subtract the items.
So the subtraction would need to be moved below within if allMaterialsFound:

The implementation details depend on how you set up the data structures of materialsNeeded and slot.item. Can’t tell you that from the screenshot.

materialsNeeded is an array of items, and slot.item is an item - so you need to check more like
if materialsNeeded.has(slot.item)