Hi, I’m building a class of data to keep the most used type in my game, it’s all fine but I need to specify change or logical operators, for example when I use == the compiler checks a specific attribute in the type and not the whole of it, or when I use new_type_var -= 20 it does exactly what it should, I haven’t found anything about this. um, but I think it should be possible, as a lot of classes have operators like this (you can check the documentation).
Does anyone have any information on how to do it? I think it should be a function with a special name…
As far as I can see, there is nothing like that built-in currently.
You can make your own function equals() that compares the values of the underlying properties of the object instead of the reference.
I know what you’re aiming for, but I don’t think that’s possible currently in GDScript.
You can try doing that in C#, but I haven’t tried it, so can’t say if this will work.
And I think that even if you do it this way it will work in C# scripts only and not GDScript.
You can open a proposal on Godot GitHub if you see value in that, although I suspect it might be harder (if not impossible) to implement with the non-static language.