@@ -404,11 +404,11 @@ between parentheses and separated by commas.
404404
405405Both of these are the same::
406406
407- @onready
408- @export_node_path("TextEdit", "LineEdit")
409- var input_field
407+ @annotation_a
408+ @annotation_b
409+ var variable
410410
411- @onready @export_node_path("TextEdit", "LineEdit") var input_field
411+ @annotation_a @annotation_b var variable
412412
413413.. _doc_gdscript_onready_annotation :
414414
@@ -435,6 +435,29 @@ can replace the above code with a single line::
435435
436436 @onready var my_label = get_node("MyLabel")
437437
438+ .. warning ::
439+
440+ Applying ``@onready `` and any ``@export `` annotation to the same variable
441+ doesn't work as you might expect. The ``@onready `` annotation will cause
442+ the default value to be set after the ``@export `` takes effect and will
443+ override it::
444+
445+ @export var a = "init_value_a"
446+ @onready @export var b = "init_value_b"
447+
448+ func _init():
449+ prints(a, b) # init_value_a <null>
450+
451+ func _notification(what):
452+ if what == NOTIFICATION_SCENE_INSTANTIATED:
453+ prints(a, b) # exported_value_a exported_value_b
454+
455+ func _ready():
456+ prints(a, b) # exported_value_a init_value_b
457+
458+ Therefore, the ``ONREADY_WITH_EXPORT `` warning is generated, which is treated
459+ as an error by default. We do not recommend disabling or ignoring it.
460+
438461Comments
439462~~~~~~~~
440463
@@ -911,7 +934,7 @@ want to assign consecutive integers to some constant.
911934::
912935
913936 enum {TILE_BRICK, TILE_FLOOR, TILE_SPIKE, TILE_TELEPORT}
914-
937+
915938 # Is the same as:
916939 const TILE_BRICK = 0
917940 const TILE_FLOOR = 1
@@ -930,10 +953,10 @@ a dictionary can also be used with a named enum.
930953::
931954
932955 enum State {STATE_IDLE, STATE_JUMP = 5, STATE_SHOOT}
933-
956+
934957 # Is the same as:
935958 const State = {STATE_IDLE = 0, STATE_JUMP = 5, STATE_SHOOT = 6}
936-
959+
937960 func _ready():
938961 # Access values with Name.KEY, prints '5'
939962 print(State.STATE_JUMP)
0 commit comments