godot icon indicating copy to clipboard operation
godot copied to clipboard

Fix `find_children` doesn't work with class names

Open nongvantinh opened this issue 1 year ago • 1 comments

Script::get_name() and Script::get_path() of inner classes return empty values. I'm unsure whether this is a bug with scripting languages or by design. This PR only addresses the bug for the outer class.

Fix: #85690

nongvantinh avatar Dec 06 '23 14:12 nongvantinh

What about the idea of adding a new parameter at the end of this function? This parameter would be a predicate function that takes the full path of the node it found, and the user will decide what to do with it.

find_children(..., Predicate p_pred = [](String path)->{return true}) const;

nongvantinh avatar Dec 07 '23 01:12 nongvantinh

Of course, we could add support for global script classes in addition to native classes (registered in ClassDB). However, this raises a larger problem: we don't have first class types, i.e. a type to represent a type. Or at least a generic FQTN (fully qualified type name). Arbitrary types are not supported not only by find_node(), but also in the Inspector and other places. So, in addition to George's point, perhaps we should discuss the larger problem first before solving special cases?

dalexeev avatar Jun 04 '24 12:06 dalexeev