소스 검색

Update style guide for new export and setget syntax

Mara Huldra 2 년 전
부모
커밋
6336d03a3a
1개의 변경된 파일11개의 추가작업 그리고 7개의 파일을 삭제
  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)
 
-    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
 
 
@@ -777,11 +779,13 @@ variables, in that order.
 
    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