I have a couple of basic lights for my game that all work the same bar the sprite texture. Hence I wanted to update this one via code and to see the result in the editor. For that, I added @tool at the top and then the following code:

@tool
extends Node2D

const paths = {
	'light_0': preload("res://graphics/lights/textures/light_0.png"),
	'light_1': preload("res://graphics/lights/textures/light_1.png"),
	'light_2': preload("res://graphics/lights/textures/light_2.png"),
	'light_3': preload("res://graphics/lights/textures/light_3.png"),
	'light_4': preload("res://graphics/lights/textures/light_4.png"),
	'light_5': preload("res://graphics/lights/textures/light_5.png"),
}

@export_enum('light_0','light_1','light_2', 'light_3', 'light_4', 'light_5') var type = 'light_0':
	set(value):
		type = value
		if value:
			$Sprite2D.texture = paths[value]
	get:
		return type 

This kinda works, the sprite texture is updated, but I get the error message: @type_setter(): Can't use get_node() with absolute paths from outside the active scene tree. I have no idea what that means, would really appreciate some help with this one.

    4 days later

    izNoob you can't use get_node.

    doing $Sprite2D is the equivalent of doing get_node("Sprite2D")

    as you can see the path is local, so it makes sense.

    1 - you should check if you are in the editor before running @tool code.
    2 - if that doesn't fix it, I can't help you without more info.