How to @export Callable?

Godot Version



Hello folks!
I’m working on procedural terrain plugin for Godot 4.2.
So far so good, however I’m stuck with editor tool stuff. I have different parameters @exported to the editor. Since the terrain is procedural, ideally I would like to pass some Callable to my node. I can do it via code, but I would like it to be configurable via editor as well.

If I make it like this:

@export height: Callable

then I get disabled control which is useless (see this thread).

As a temporary workaround, I created a Node parameter:

@export var height_node: Node

So I create some node with a script containing a get_height function, and inside my terrain’s code I call it like

var height = height_node.get_height(x, y)

It works but looks ugly, so I was curious whether there is some better / canonical approach to set a callable as editor parameter.

Thank you!

How do you envision the user filling in this export?
Are you going to have them type some code in via the inspector?
(Sorry, I don’t know how to export a callable).

Yep, I thought maybe some “type function” popup editor or “select function” selectbox, or something else commonly used in godot…

1 Like