Godot Version
Godot 4.3.stable
Question
I’m working on an editor plugin which will have a dock and some buttons. Right at launch it checks if it can open a directory to a cache file, and whether it can open an “world edit scene” which i use so i can keep track of ether or not the scene its responsible for is being edited. if it cant do these things it changes the properties of some of the buttons on the dock which are declared with @onready, but its returning errors as if the nodes hadnt loaded yet. ill show the the relevant parts of the code:
@tool
extends VBoxContainer
@onready var FirstWorldContextButton : Button = $ControlPanel/WorldInspector/FirstButton
@onready var SecondWorldContextButton : Button = $ControlPanel/WorldInspector/SecondButton
@onready var Info : Label = $ProcessInfo
func _enter_tree() -> void:
var LockOpenDisplay : Callable = func(Message : String) -> void:
Info.label_settings.font_color = Color.LIGHT_CORAL
Info.label_settings.outline_color = Color.BLACK
Info.label_settings.outline_size = 50
Info.text = Message
# worldcontextdisplay is a node in the dock that changes at runtime
# but it works fine, not the issue here
var TextDisplay : Label = set_WorldContextDisplay("Label")
TextDisplay.text = Message
FirstWorldContextButton.disabled = true
FirstWorldContextButton.text = "..."
SecondWorldContextButton.disabled = true
SecondWorldContextButton.text = "..."
return
for child in get_children():
print(child)
var DAccess : DirAccess
if(!IO.open_dir(DAccess, IO.TreeCacheDir)):
LockOpenDisplay.call("FAILED TO OPEN OR CREATE CACHE DIRECTORY")
elif !open_editorcontext_worldedit_scene():
LockOpenDisplay.call("FAILED TO OPEN OR CREATE WORLD EDIT SCENE")
else:
#do stuff here ...
But when i run, i get the following errors:
res://addons/skylark_world_builder/tools/tree_sitter_dock.gd:82 - Cannot call method 'pack' on a null value.
res://addons/skylark_world_builder/tools/tree_sitter_dock.gd:36 - Invalid access to property or key 'label_settings' on a base object of type 'Nil'.
ControlPanel:<VBoxContainer#1762127836193>
TreeScrollContainer:<ScrollContainer#1762429826099>
ProcessInfo:<Label#1763335795812>
res://addons/skylark_world_builder/tools/tree_sitter_dock.gd:82 - Cannot call method 'pack' on a null value.
res://addons/skylark_world_builder/tools/tree_sitter_dock.gd:36 - Invalid assignment of property or key 'font_color' with value of type 'Color' on a base object of type 'null instance'.
res://addons/skylark_world_builder/tools/tree_sitter_dock.gd:82 - Cannot call method 'pack' on a null value.
res://addons/skylark_world_builder/tools/tree_sitter_dock.gd:36 - Invalid access to property or key 'label_settings' on a base object of type 'Nil'.
res://addons/skylark_world_builder/tools/tree_sitter_dock.gd:82 - Cannot call method 'pack' on a null value.
res://addons/skylark_world_builder/tools/tree_sitter_dock.gd:36 - Invalid access to property or key 'label_settings' on a base object of type 'Nil'.
ControlPanel:<VBoxContainer#1762127836193>
TreeScrollContainer:<ScrollContainer#1762429826099>
ProcessInfo:<Label#1763335795812>
ControlPanel:<VBoxContainer#1791890617054>
TreeScrollContainer:<ScrollContainer#1792192606922>
ProcessInfo:<Label#1793098576537>
ControlPanel:<VBoxContainer#1796084920973>
TreeScrollContainer:<ScrollContainer#1796386910845>
ProcessInfo:<Label#1797292880460>
I tried changing the _enter_tree() function to be _ready(), but it makes no difference and the errors are identical. printing the nodes seems to imply that these errors are happening during or even before the actual code should be accessed. I thought it could be that I had i had the LockkOpenDisplay function as a lambda, but i moved that out into its own function and im getting the same errors. Heres the scene tree for the dock:
Any ideas whats going on here? Am i just misunderstanding something? Any and all help would be appreciated.