godotengine / godot-proposals

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

Support Arrays with NodePaths #7221

Open CactiChameleon9 opened 1 year ago

CactiChameleon9 commented 1 year ago

Describe the project you are working on

A Neutral-Network Plugin for Godot, in which users can write in an @export Array[String] to represent the inputs/outputs from the network.

Describe the problem or limitation you are having in your project

It is not possible to access an item in an array using get_indexed(my_string)
All other properties, including parts of vectors, can be referenced this way... except items in arrays

For me, this means that I need to use lots of member variables (var raycast1; var raycast2; var raycast3 ...) instead of an array raycasts[1], raycasts[2]... because the variables inside an array cannot gotten from a string

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

It should be possible to use a similar syntax to subproperties (like with position:x or rectangle:size) to access items in an array via a nodepath

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

I think either:

to try and match the existing syntax (where the number is the index of an item in an array)

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

I, in this specific usecase, could add specific support for arrays assuming that all the contents of the array would want to be used in the network
However I believe this should be a feature for consistencies sake... I was under the assumption that NodePaths could access all the variables of a given node, except this is not true

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

GDScript core feature

CactiChameleon9 commented 1 year ago

@JoNax97 I rephrased this request, does it make more sense?

JoNax97 commented 1 year ago

Yes, thanks!