From a30183a4c48ce5a1f4354b47b3be48ba106b1bad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Mon, 28 Jan 2019 12:05:20 +0100 Subject: [PATCH] Fix GDScript enum docs for 3.1 --- .../scripting/gdscript/gdscript_basics.rst | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/getting_started/scripting/gdscript/gdscript_basics.rst b/getting_started/scripting/gdscript/gdscript_basics.rst index 1f6a5a699..a87158103 100644 --- a/getting_started/scripting/gdscript/gdscript_basics.rst +++ b/getting_started/scripting/gdscript/gdscript_basics.rst @@ -658,8 +658,12 @@ Enums Enums are basically a shorthand for constants, and are pretty useful if you want to assign consecutive integers to some constant. -If you pass a name to the enum, it would also put all the values inside a -constant dictionary of that name. +If you pass a name to the enum, it will put all the keys inside a constant +dictionary of that name. + +.. important: The keys in a named enum are not registered as global constants + in Godot 3.1 and later, they should be accessed prefixed by the + enum's name (``Name.KEY``). See example below. :: @@ -672,10 +676,8 @@ constant dictionary of that name. enum State {STATE_IDLE, STATE_JUMP = 5, STATE_SHOOT} # Is the same as: - const STATE_IDLE = 0 - const STATE_JUMP = 5 - const STATE_SHOOT = 6 const State = {STATE_IDLE = 0, STATE_JUMP = 5, STATE_SHOOT = 6} + # Access values with State.STATE_IDLE, etc. Functions