godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.12k stars 69 forks source link

Improve GraphEdit's is_valid_connection_type method #7555

Open CsloudX opened 1 year ago

CsloudX commented 1 year ago

Describe the project you are working on

No-Game App

Describe the problem or limitation you are having in your project

Sometimes, I want check to slot can connection. I must coding like this:

if (from_type==to_type) or (is_valid_connection_type(from_type,to_type):
    # coding here

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Anytime, the same type always can connect, but is_valid_connection_type(TYPE_INT,TYPE_INT) return false, it's not make sense.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

For is_valid_connection_type(from_type,to_type), if from_type==to_type, it should return true.

If this enhancement will not be used often, can it be worked around with a few lines of script?

if (from_type==to_type) or (is_valid_connection_type(from_type,to_type):
    # coding here

Is there a reason why this should be core and not an add-on in the asset library?

/

DrMouseInc commented 4 months ago

Running into this exact issue when loading a saved GraphEdit from file. IsValidConnectionType (in C# parlance) should absolutely return true when fromType == toType. Additionally the ConnectNode() method returns Error.Ok for a connection for which IsValidConnectionType returns false which seems pretty counterintuitive.