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
Because the UI in the app is getting more complex, I often have a hierarchy of 7+ nodes. While working with buttons, I sometimes need to use the get_parent( ) function 3 times in a row to get to the node I want to use, which makes the code look harder to read.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Add an optional int parameter to the get_parent( ) function that specifies how many times in a row you want to use the function. That will help make the code cleaner and easier to read. The function should accept values >=1.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Let's take a scene with this hierarchy:
/root/Node1/Node2/Node3/Node4/Node5
Node5 has the node5.gd script attached.
If we want to get the name of the node three ranks higher in the node hierarchy (Node2), in node5.gd we would have the code:
If this enhancement will not be used often, can it be worked around with a few lines of script?
It can be worked around with a recursive function:
func repeat_get_parent(times : int, node):
if times > 1:
return repeat_get_parent(times-1, node.get_parent())
elif times == 1:
return node.get_parent()
Is there a reason why this should be core and not an add-on in the asset library?
get_parent( ) is a commonly used function and I think having an optional parameter to make it easier and cleaner in code to do certain tasks should be a great addition to many Godot users.
The text was updated successfully, but these errors were encountered:
Describe the project you are working on
A text editor app
Describe the problem or limitation you are having in your project
Because the UI in the app is getting more complex, I often have a hierarchy of 7+ nodes. While working with buttons, I sometimes need to use the get_parent( ) function 3 times in a row to get to the node I want to use, which makes the code look harder to read.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Add an optional int parameter to the get_parent( ) function that specifies how many times in a row you want to use the function. That will help make the code cleaner and easier to read. The function should accept values >=1.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Let's take a scene with this hierarchy:
/root/Node1/Node2/Node3/Node4/Node5
Node5 has the node5.gd script attached.
If we want to get the name of the node three ranks higher in the node hierarchy (Node2), in node5.gd we would have the code:
instead of the more complicated:
It's the equivalent of
get_node("../../../")
If this enhancement will not be used often, can it be worked around with a few lines of script?
It can be worked around with a recursive function:
Is there a reason why this should be core and not an add-on in the asset library?
get_parent( ) is a commonly used function and I think having an optional parameter to make it easier and cleaner in code to do certain tasks should be a great addition to many Godot users.
The text was updated successfully, but these errors were encountered: