godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.47k stars 21.26k forks source link

Toggling the `sequenced` property of `VisualScriptFunction` doesn't redraw/refesh call nodes #37173

Open follower opened 4 years ago

follower commented 4 years ago

Godot version: v3.2.1.stable.official

OS/device including version: N/A

Issue description:

The sequenced property of VisualScriptFunction is (AFAICT) supposed to enable a function to act as a getter, however:

  1. The functionality is undocumented (see: https://github.com/godotengine/godot-docs/issues/3287).

  2. There is an apparent bug which makes the functionality--at a minimum--undiscoverable and potentially broken.

Steps to reproduce:

Here is an example of how the sequenced property is intended to be used:

godot-visualscript-function-sequenced-example

Configuration:

In the above image, note the following:

Also, with this configuration, if the call to functionA() is not connected as part of a sequence then an error is generated by the Add node:

Add: Invalid arguments A: Nil B int

Minimal reproduction project:

The below image shows an example of what happens if sequenced is toggled on functionA and another call node is created by dragging the function name from the "Functions" list onto the graph:

godot-visualscript-function-sequenced-bug-demo

Note:

There is more detail in the documentation-related issue linked above. (Including discussion about whether there's an underlying feature design/exposure issue to consider and uncertainty about potential caching/consts issues.)

Potential solutions

My impression is that a bug fix would need to cover two parts:

  1. Visual refresh of existing displayed function call nodes.

  2. Handling of connections/disconnections of existing function call nodes when the referenced function's sequenced property is set to false--including potentially warning about unintended changes.

Related links

theoway commented 4 years ago

So all the functions with sequence property set to false, will they be called at the same time? Or do they act as getters?

follower commented 4 years ago

So all the functions with sequence property set to false, will they be called at the same time? Or do they act as getters?

My understanding is that the functions act as getters.

theoway commented 4 years ago

A better way to solve it would be to refresh the nodes, like you mentioned. Because if the sequence property is changed, it would depend on the user on how to connect/reconnect the node.

follower commented 4 years ago

Because if the sequence property is changed, it would depend on the user on how to connect/reconnect the node.

From a "principle of least surprise" point of view:

FWIW I do feel like the sequenced property being exposed is somewhat unintentional leaking of an implementation detail and that a better approach would be to just automatically treat a "non-sequenced" node as a getter when the output data port is only port connected.

follower commented 4 years ago

But, yes, at a minimum, visually refreshing the nodes would be an improvement on the existing behaviour, even if it may not be ideal.

swarnimarun commented 4 years ago

Yep I do agree, that sequenced is rather obtuse and probably should be removed in-favor of automatically detecting no sequence port connections. Or having grayed out sequence ports unless connected displaying capacity to work without the sequence ports.

As for the redrawing part, it is simple enough so maybe it's fine as a bandage.

theoway commented 4 years ago

But, yes, at a minimum, visually refreshing the nodes would be an improvement on the existing behaviour, even if it may not be ideal.

Yup, sure it will be. I'll be making a PR to refresh those nodes. This way there will be some consistency with the property change. Also, it's not only with sequence ports. The arguments also don't get updated when number of arguments are changed in function node.