0 votes

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! :)

in Engine by (15 points)

1 Answer

0 votes
Best answer

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.

by (5,248 points)
selected by

Thanks avencherus, that works! :)

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.

Quite welcome. ^_^

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.