Browse Source

Add array export hints to the docs

Refs godotengine/godot#16418, closes #326
Bojidar Marinov 7 years ago
parent
commit
05a3d08533
1 changed files with 13 additions and 2 deletions
  1. 13 2
      getting_started/scripting/gdscript/gdscript_basics.rst

+ 13 - 2
getting_started/scripting/gdscript/gdscript_basics.rst

@@ -1140,7 +1140,18 @@ initializers, but they must be constant expressions.
     # Exported array, shared between all instances.
     # Default value must be a constant expression.
 
-    export var a=[1,2,3]
+    export var a = [1, 2, 3]
+
+    # Exported arrays can specify type (using the same hints as before)
+
+    export(Array, int) var ints = [1,2,3]
+    export(Array, int, "Red", "Green", "Blue") var enums = [2, 1, 0]
+    export(Array, Array, float) var two_dimensional = [[1, 2], [3, 4]]
+
+    # You can omit the default value, but then it would be null if not assigned
+
+    export(Array) var b
+    export(Array, PackedScene) var scenes
 
     # Typed arrays also work, only initialized empty:
 
@@ -1151,7 +1162,7 @@ initializers, but they must be constant expressions.
     # Default value can include run-time values, but can't
     # be exported.
 
-    var b = [a,2,3]
+    var c = [a, 2, 3]
 
 
 Setters/getters