Replies: 2 comments 2 replies
-
Why is |
Beta Was this translation helpful? Give feedback.
-
I made this proposal because i thought that you can't add methods to built-in classes. You can't, but you can make a global script that has similar functionality and right now i'm working on adding these and some other functions in a helper global script over here: https://github.com/tomsterBG/godot-classes-unit-tested |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
It's easy to script a for loop to iterate on all children and check which one is of a certain class. Similarly to check which one has a method or signal. Similarly to do that in reverse for your parents. However i think it's so frequently done that it deserves to be matured as an official set of helper functions along the already existing methods.
I find it easier to search for a node of a group than a node of a class because of the helper method. However groups solve a specific problem and i think it doesn't mean we can't have easily searchable nodes by other traits, especially commonly looked at ones like class and method, and perhaps signal. Arguably both of these focus more on what a node does rather than what it is.
Here's the more specific proposal:
I'm indecisive on the names, but the idea is there. It'd be easy to do and optimize in the future if the Object
is_class()
,has_method()
andhas_signal()
methods are used.On a side note, why
is_class
andtype
are used for the same thing? I feel like there's a distinction that is important like maybetype
refers to all classes, even throughclass_name
unlikeclass
referring only to built-in ones?As for usecases i just bumped into it yet again, wanting to find my children by their class simply because by name is less reliable, I may change the name, but the class doesn't just change at my will because i need it for its functionality and that is more reliably searchable in my case.
Beta Was this translation helpful? Give feedback.
All reactions