Merge pull request #2714 from nippysaurus/patch-1

correct variable reference in setget example
This commit is contained in:
Rémi Verschelde
2019-09-01 15:46:35 +02:00
committed by GitHub

View File

@@ -1202,7 +1202,7 @@ will be called. This happens *before* the value is changed. The *setter* must de
with the new value. Vice versa, when ``variable`` is accessed, the *getter* function
(``getterfunc`` above) must ``return`` the desired value. Below is an example::
var myvar setget my_var_set, my_var_get
var my_var setget my_var_set, my_var_get
func my_var_set(new_value):
my_var = new_value
@@ -1213,9 +1213,9 @@ with the new value. Vice versa, when ``variable`` is accessed, the *getter* func
Either of the *setter* or *getter* functions can be omitted::
# Only a setter.
var my_var = 5 setget myvar_set
var my_var = 5 setget my_var_set
# Only a getter (note the comma).
var my_var = 5 setget ,myvar_get
var my_var = 5 setget ,my_var_get
Setters and getters are useful when :ref:`exporting variables <doc_gdscript_exports>`
to the editor in tool scripts or plugins, for validating input.