godotengine / godotengine/godot-visual-script

Issues and feedback on programmatically adding visual scripting nodes

Open
#46 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
C++
Stars
131
Forks
25
PR merge metrics
No merged PRs in 30d

Description

Currently you can add visual scripting nodes through the VisualScript class, so in theory it's possible to add nodes to the visual script when you drag in a custom visual script. However this is unreliable and perhaps and I'm doing this wrong. Sometimes the node I try to add to the scene does not want to show up.

A couple issues:
1) For visualscript.add_node(), you need 2 parameters that are not readily accessible through scripts, the name of the function to place the node in, and the id to give the node. One issue is you don't know what id's are already taken unless you look the values that hidden in visualscript.data. The name of functions aren't also easy to acquire being hidden in visualscript.data as well.

solutions:
1) VisualScriptCustomNode.get_function_name() - get the current function the node belongs to
2) In VisualScript.add_node() If id isn't assigned, automatically assign an unused id.
3) VisualScriptCustomNode._added_to_script() (this could be what _init is for) ~ ran once after the node is created and added to the scene, used for adding nodes to the scene and other operations, like a _ready function I guess.
4) Getting the assigned id of a custom node, from the custom node, would also be helpful
5) Getting the position of a custom node, from the custom node, would also be helpful, to line up additional nodes
6) Directly connecting ports, from Custom Nodes rather than having to go through VisualScript, would be less cumbersome

Bug???:
Even if you provide an unused ID and the proper function, it's not always guaranteed the node will be added to the scene. This is the code that sometimes works.

```
tool
extends VisualScriptCustomNode
...
...
func _init():
var vs = get_visual_script()
var node = VisualScriptSceneNode.new()
node.node_path = '.'
if(vs != null):
var index = vs.data.functions[0].nodes[vs.data.functions[0].nodes.size() - 3]
vs.add_node("_physics_process",index+1,node)
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.