Browse Source

Update code snippet to Godot 4 (#8114)

* Update code snippet to Godot 4

* Update tutorials/best_practices/godot_notifications.rst

---------

Co-authored-by: Max Hilbrunner <[email protected]>
HolonProduction 1 year ago
parent
commit
a0789aae63
1 changed files with 5 additions and 8 deletions
  1. 5 8
      tutorials/best_practices/godot_notifications.rst

+ 5 - 8
tutorials/best_practices/godot_notifications.rst

@@ -177,18 +177,15 @@ instantiation:
     # "one" is an "initialized value". These DO NOT trigger the setter.
     # If someone set the value as "two" from the Inspector, this would be an
     # "exported value". These DO trigger the setter.
-    export(String) var test = "one" setget set_test
+    @export var test: String = "one":
+        set(value):
+            test = value
+            print("Setting: ", test)
 
     func _init():
         # "three" is an "init assignment value".
-        # These DO NOT trigger the setter, but...
+        # Trigger the setter
         test = "three"
-        # These DO trigger the setter. Note the `self` prefix.
-        self.test = "three"
-
-    func set_test(value):
-        test = value
-        print("Setting: ", test)
 
   .. code-tab:: csharp