Editor Plugin: is it possible to assign / set a variable in another node?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By birdWord
:warning: Old Version Published before Godot 3 was released.

Hello, I am making my first editor plugin at the moment, and I am trying to change an export var in a node that is selected in the editor. I have got the list of selected nodes no problem, and I can read the value of the export var from my selected node, but I am stumped as to how to actually set the value (for instance when I press a button, I want the value to update in the editor).

A simple nodeName.variableName = newValue doesn’t appear to work.

Is my problem related to setget?

If anyone can shed some light on this, I would be grateful! :slight_smile:

:bust_in_silhouette: Reply From: avencherus

Yes, you’ll want to use the syntax:

get_node('path/name').variableName = value

The setget keyword gives you option to attach custom setter and getter functions to handle when the value is changed.

Thanks avencherus, that works! :slight_smile:

A note for anyone who reads this after who might be confused by it, the updated export var will only display once you have clicked away from the target node and selected it again.

birdWord | 2016-09-17 21:28

Quite welcome. :slight_smile:

avencherus | 2016-09-17 21:32