Browse Source

Update style guide for new export and setget syntax

Mara Huldra 2 years ago
parent
commit
6336d03a3a
1 changed files with 11 additions and 7 deletions
  1. 11 7
      tutorials/scripting/gdscript/gdscript_styleguide.rst

+ 11 - 7
tutorials/scripting/gdscript/gdscript_styleguide.rst

@@ -35,10 +35,12 @@ Here is a complete class example based on these guidelines:
 
 
     signal state_changed(previous, new)
     signal state_changed(previous, new)
 
 
-    export var initial_state = NodePath()
-    var is_active = true setget set_is_active
+    @export var initial_state: Node
+    var is_active = true:
+        set = set_is_active
 
 
-    @onready var _state = get_node(initial_state) setget set_state
+    @onready var _state = initial_state:
+        get = set_state
     @onready var _state_name = _state.name
     @onready var _state_name = _state.name
 
 
 
 
@@ -777,11 +779,13 @@ variables, in that order.
 
 
    const MAX_LIVES = 3
    const MAX_LIVES = 3
 
 
-   export(Jobs) var job = Jobs.KNIGHT
-   export var max_health = 50
-   export var attack = 5
+   @export var job: Jobs = Jobs.KNIGHT
+   @export var max_health = 50
+   @export var attack = 5
 
 
-   var health = max_health setget set_health
+   var health = max_health:
+       set(new_health):
+           health = new_health
 
 
    var _speed = 300.0
    var _speed = 300.0