|
@@ -75,7 +75,7 @@ here's a simple example of how GDScript looks.
|
|
const answer = 42
|
|
const answer = 42
|
|
const thename = "Charly"
|
|
const thename = "Charly"
|
|
|
|
|
|
- # enums (Godot 2.2+)
|
|
|
|
|
|
+ # enums
|
|
|
|
|
|
enum {UNIT_NEUTRAL, UNIT_ENEMY, UNIT_ALLY}
|
|
enum {UNIT_NEUTRAL, UNIT_ENEMY, UNIT_ALLY}
|
|
enum Named {THING_1, THING_2, ANOTHER_THING = -1}
|
|
enum Named {THING_1, THING_2, ANOTHER_THING = -1}
|
|
@@ -187,7 +187,7 @@ keywords are reserved words (tokens), they can't be used as identifiers.
|
|
+------------+---------------------------------------------------------------------------------------------------------------+
|
|
+------------+---------------------------------------------------------------------------------------------------------------+
|
|
| const | Defines a constant. |
|
|
| const | Defines a constant. |
|
|
+------------+---------------------------------------------------------------------------------------------------------------+
|
|
+------------+---------------------------------------------------------------------------------------------------------------+
|
|
-| enum | Defines an enum. (Godot 2.2+) |
|
|
|
|
|
|
+| enum | Defines an enum. |
|
|
+------------+---------------------------------------------------------------------------------------------------------------+
|
|
+------------+---------------------------------------------------------------------------------------------------------------+
|
|
| var | Defines a variable. |
|
|
| var | Defines a variable. |
|
|
+------------+---------------------------------------------------------------------------------------------------------------+
|
|
+------------+---------------------------------------------------------------------------------------------------------------+
|
|
@@ -241,7 +241,7 @@ The following is the list of supported operators and their precedence
|
|
+---------------------------------------------------------------+-----------------------------------------+
|
|
+---------------------------------------------------------------+-----------------------------------------+
|
|
| ``or`` ``||`` | Boolean OR |
|
|
| ``or`` ``||`` | Boolean OR |
|
|
+---------------------------------------------------------------+-----------------------------------------+
|
|
+---------------------------------------------------------------+-----------------------------------------+
|
|
-| ``if x else`` | Ternary if/else (Godot 2.2+) |
|
|
|
|
|
|
+| ``if x else`` | Ternary if/else |
|
|
+---------------------------------------------------------------+-----------------------------------------+
|
|
+---------------------------------------------------------------+-----------------------------------------+
|
|
| ``=`` ``+=`` ``-=`` ``*=`` ``/=`` ``%=`` ``&=`` ``|=`` | Assignment, Lowest Priority |
|
|
| ``=`` ``+=`` ``-=`` ``*=`` ``/=`` ``%=`` ``&=`` ``|=`` | Assignment, Lowest Priority |
|
|
+---------------------------------------------------------------+-----------------------------------------+
|
|
+---------------------------------------------------------------+-----------------------------------------+
|
|
@@ -531,8 +531,6 @@ expressions and must be assigned on initialization.
|
|
Enums
|
|
Enums
|
|
^^^^^
|
|
^^^^^
|
|
|
|
|
|
-*Note, only available in Godot 2.2 or higher.*
|
|
|
|
-
|
|
|
|
Enums are basically a shorthand for constants, and are pretty useful if you
|
|
Enums are basically a shorthand for constants, and are pretty useful if you
|
|
want to assign consecutive integers to some constant.
|
|
want to assign consecutive integers to some constant.
|
|
|
|
|
|
@@ -653,8 +651,7 @@ Short statements can be written on the same line as the condition::
|
|
return x
|
|
return x
|
|
|
|
|
|
Sometimes you might want to assign a different initial value based on a
|
|
Sometimes you might want to assign a different initial value based on a
|
|
-boolean expression. In this case ternary-if expressions come in handy
|
|
|
|
-(Godot 2.2+)::
|
|
|
|
|
|
+boolean expression. In this case ternary-if expressions come in handy::
|
|
|
|
|
|
var x = [true-value] if [expression] else [false-value]
|
|
var x = [true-value] if [expression] else [false-value]
|
|
y += 3 if y < 10 else -1
|
|
y += 3 if y < 10 else -1
|
|
@@ -1312,13 +1309,13 @@ signal is received, execution will recommence. Here are some examples:
|
|
::
|
|
::
|
|
|
|
|
|
# Resume execution the next frame
|
|
# Resume execution the next frame
|
|
- yield( get_tree(), "idle_frame" )
|
|
|
|
|
|
+ yield(get_tree(), "idle_frame")
|
|
|
|
|
|
# Resume execution when animation is done playing:
|
|
# Resume execution when animation is done playing:
|
|
- yield( get_node("AnimationPlayer"), "finished" )
|
|
|
|
|
|
+ yield(get_node("AnimationPlayer"), "finished")
|
|
|
|
|
|
- # Wait 5 seconds, then resume execution (Godot 2.2+)
|
|
|
|
- yield( get_tree().create_timer(5.0), "timeout" )
|
|
|
|
|
|
+ # Wait 5 seconds, then resume execution
|
|
|
|
+ yield(get_tree().create_timer(5.0), "timeout")
|
|
|
|
|
|
Onready keyword
|
|
Onready keyword
|
|
~~~~~~~~~~~~~~~
|
|
~~~~~~~~~~~~~~~
|