How to give value to TextureRect

Godot Version

Hi everyone,

I am trying to create a code where if a texture rect is equal to certain image that gives it a certain value.

For more context I am using drag and drop

This part is where I am struggling:

if texture == ("res://design rules/Microgriddy (4).png") : value += 100

I am receiving an error stating
Invalid operands "Texture2D" and "String" for "==" operator.

Question

Please let me know if I can provide more details!

You need to load the texture path

const microgriddy = preload("res://design rules/Microgriddy (4).png")

if texture == microgriddy:
    value += 100
1 Like