You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the problem or limitation you are having in your project
I need a way to get the object the signal happened on without having to manually bind a nodepath each time
Describe the feature / enhancement and how it helps to overcome the problem or limitation
signals would just be redefined as signal(args...) to signal(sender:<SelfObjectTypeHere>, args...)
they would be statically typed it the background but using the static typing in the callback signature would be optional
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
# Nodesignaldo_somethingdo_something.connect(_on_do_something)
do_something.emit()
# sender is automatically passed infunc_on_do_something(sender:Node)->void:
pass
# Node2Dsignaldo_somethingdo_something.connect(_on_do_something)
do_something.connect(_on_do_something2)
do_something.emit()
# sender is automatically passed infunc_on_do_something(sender:Node2D)->void:
pass# error! signal must accept first argument as type selffunc_on_do_something2()->void:
pass
If this enhancement will not be used often, can it be worked around with a few lines of script?
It can be worked around but it requires awkwardly binding a additional argument when signals should already carry that info.
Is there a reason why this should be core and not an add-on in the asset library?
It improves the godot messaging system
The text was updated successfully, but these errors were encountered:
Shadowblitz16
changed the title
Nodes should send themselves as first argument to any signal
Objects should send themselves as first argument to any signal
Jun 27, 2023
Doing this by default would break compatibility with existing projects, as the number of arguments would change for all signal functions (and you can't have a mismatch).
It can be worked around but it requires awkwardly binding a additional argument when signals should already carry that info.
In Godot signals normally don't carry any information that you can get otherwise. Binding the node that you already have a reference to is the correct and expected way. Same goes for any other information that you can determine at connect or at emit time without extra arguments. So your suggestion goes against the design principle of the engine.
Describe the project you are working on
A spaceship game
Describe the problem or limitation you are having in your project
I need a way to get the object the signal happened on without having to manually bind a nodepath each time
Describe the feature / enhancement and how it helps to overcome the problem or limitation
signals would just be redefined as
signal(args...)
tosignal(sender:<SelfObjectTypeHere>, args...)
they would be statically typed it the background but using the static typing in the callback signature would be optional
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
If this enhancement will not be used often, can it be worked around with a few lines of script?
It can be worked around but it requires awkwardly binding a additional argument when signals should already carry that info.
Is there a reason why this should be core and not an add-on in the asset library?
It improves the godot messaging system
The text was updated successfully, but these errors were encountered: